Blog Or IT News

We present and write attractive Tech blog posts

Git CheetCode

Here are some commonly used Git commands and their brief explanations

Configuration

git config --global user.name "Your Name" - Sets your username in Git.

git config --global user.email "youremail@example.com" - Sets your email address in Git.

Creating a Repository

git init - Initializes a new Git repository.

git clone - Clones an existing Git repository.

Making Changes

git add - Adds a file to the staging area.

git add . - Adds all changes to the staging area.

git commit -m "Commit message" - Commits changes to the local repository with a message.

git commit -am "Commit message" - Stages and commits changes in one command.

git rm - Removes a file from the working directory and stages the deletion.

git mv - Renames a file and stages the change.

Branching

git branch - Lists all branches in the current repository.

git branch - Creates a new branch with the specified name.

git checkout - Switches to the specified branch.

git merge - Merges the specified branch into the current branch.

git push origin - Pushes the specified branch to the remote repository.

git branch -d - Deletes the specified branch.

Syncing with Remote Repositories

git fetch - Fetches changes from the remote repository.

git pull - Fetches changes and merges them into the current branch.

git push - Pushes changes to the remote repository.

Other Useful Commands

git status - Shows the status of the working directory and staging area.

git log - Shows a list of all commits in the current branch.

git diff - Shows the differences between the working directory and the staging area.

git blame - Shows the author and revision history of each line in a file.

I hope this cheat sheet helps you in your Git journey!

Comments :

    No Comments.

Leave A Comment :