Git Command Cheat-Sheet
Quick-reference cheat sheet for common Git commands: configuration, branching, commits, remotes, merge, rebase, and more.
Command | Description | |
---|---|---|
git config --global user.name "Your Name" | Set your Git global username. | |
git config --global user.email "[email protected]" | Set your Git global email. | |
git init | Initialize a new Git repository. | |
git clone <repository> | Clone a repository into a new directory. | |
git status | Show the working directory status. | |
git add <file> | Stage file(s) for commit. | |
git commit -m "message" | Commit staged changes with a message. | |
git log | Show commit logs. | |
git diff | Show changes between commits, commit and working tree, etc. | |
git branch | List, create, or delete branches. | |
git checkout <branch> | Switch to a branch and update the working directory. | |
git checkout -b <branch> | Create and switch to a new branch. | |
git merge <branch> | Merge specified branch into current branch. | |
git rebase <branch> | Reapply commits on top of another base tip. | |
git fetch | Download objects and refs from another repository. | |
git pull | Fetch from and integrate with another repository or branch. | |
git push | Update remote refs along with associated objects. | |
git remote -v | List remote repositories. | |
git reset --hard <commit> | Reset current HEAD to the specified state, discarding changes. | |
git revert <commit> | Revert changes from a commit by creating a new commit. | |
git stash | Stash changes in a dirty working directory. | |
git stash pop | Apply the top stash and remove it from the stash list. | |
git tag <tagname> | Create a tag object. | |
git branch -d <branch> | Delete a branch. |