Git Commands Cheat Sheet
Essential Git commands reference guide
Git Commands Cheat Sheet
Quick reference guide for Git version control commands. Click the copy button to copy any command.
87
Total Commands
87
Filtered Results
Setup and Config
Command | Copy | Description |
---|---|---|
git config --global user.name "name" | Set your name for commits | |
git config --global user.email "email" | Set your email for commits | |
git config --list | List all Git configuration | |
git config --global --edit | Edit global config file | |
git config --global core.editor "code" | Set default editor |
Creating Repositories
Command | Copy | Description |
---|---|---|
git init | Initialize new Git repository | |
git clone <url> | Clone remote repository | |
git clone <url> <directory> | Clone to specific directory |
Basic Snapshotting
Command | Copy | Description |
---|---|---|
git status | Show working tree status | |
git add <file> | Stage specific file | |
git add . | Stage all changes | |
git add -A | Stage all changes (including deletions) | |
git add -p | Interactively stage changes | |
git commit -m "message" | Commit staged changes | |
git commit -am "message" | Stage and commit all changes | |
git commit --amend | Amend last commit | |
git reset <file> | Unstage file | |
git reset --hard | Discard all changes | |
git reset --soft HEAD~1 | Undo last commit, keep changes | |
git rm <file> | Remove file and stage deletion | |
git mv <old> <new> | Move or rename file |
Branching and Merging
Command | Copy | Description |
---|---|---|
git branch | List all branches | |
git branch <name> | Create new branch | |
git branch -d <name> | Delete branch | |
git branch -D <name> | Force delete branch | |
git branch -m <new-name> | Rename current branch | |
git checkout <branch> | Switch to branch | |
git checkout -b <branch> | Create and switch to new branch | |
git switch <branch> | Switch to branch (modern) | |
git switch -c <branch> | Create and switch to new branch (modern) | |
git merge <branch> | Merge branch into current branch | |
git merge --no-ff <branch> | Merge with merge commit | |
git merge --abort | Abort merge |
Remote Repositories
Command | Copy | Description |
---|---|---|
git remote | List remote repositories | |
git remote -v | List remotes with URLs | |
git remote add <name> <url> | Add remote repository | |
git remote remove <name> | Remove remote | |
git remote rename <old> <new> | Rename remote | |
git fetch | Fetch from remote | |
git fetch <remote> | Fetch from specific remote | |
git pull | Fetch and merge from remote | |
git pull --rebase | Fetch and rebase on remote | |
git push | Push to remote | |
git push <remote> <branch> | Push branch to remote | |
git push -u origin <branch> | Push and set upstream | |
git push --force | Force push (use with caution) | |
git push --tags | Push all tags |
Inspection and Comparison
Command | Copy | Description |
---|---|---|
git log | Show commit history | |
git log --oneline | Show condensed commit history | |
git log --graph | Show commit history with graph | |
git log --all --decorate --oneline --graph | Show detailed graph (dog) | |
git log -n <number> | Show last n commits | |
git log --author="name" | Show commits by author | |
git log --since="2 weeks ago" | Show commits since date | |
git show <commit> | Show commit details | |
git diff | Show unstaged changes | |
git diff --staged | Show staged changes | |
git diff <branch1> <branch2> | Compare two branches | |
git blame <file> | Show who changed each line |
Stashing
Command | Copy | Description |
---|---|---|
git stash | Stash current changes | |
git stash save "message" | Stash with message | |
git stash list | List all stashes | |
git stash pop | Apply and remove last stash | |
git stash apply | Apply last stash | |
git stash drop | Delete last stash | |
git stash clear | Delete all stashes |
Tagging
Command | Copy | Description |
---|---|---|
git tag | List all tags | |
git tag <name> | Create lightweight tag | |
git tag -a <name> -m "message" | Create annotated tag | |
git tag -d <name> | Delete tag | |
git push origin <tag> | Push tag to remote |
Undoing Changes
Command | Copy | Description |
---|---|---|
git checkout -- <file> | Discard changes in file | |
git restore <file> | Discard changes in file (modern) | |
git restore --staged <file> | Unstage file (modern) | |
git revert <commit> | Revert commit with new commit | |
git reset HEAD~1 | Undo last commit, keep changes | |
git reset --hard HEAD~1 | Undo last commit, discard changes |
Rebasing
Command | Copy | Description |
---|---|---|
git rebase <branch> | Rebase onto branch | |
git rebase --continue | Continue rebase after resolving conflicts | |
git rebase --abort | Abort rebase | |
git rebase -i HEAD~3 | Interactive rebase last 3 commits |
Advanced
Command | Copy | Description |
---|---|---|
git cherry-pick <commit> | Apply commit to current branch | |
git clean -fd | Remove untracked files and directories | |
git reflog | Show reference logs | |
git bisect start | Start binary search for bug | |
git submodule add <url> | Add submodule | |
git submodule update --init | Initialize submodules |
All operations are performed locally in your browser. No data is sent to any server.
About Git Commands Cheat Sheet
This section will contain detailed, SEO-friendly content about the Git Commands Cheat Sheet.
In the future, this content will be managed through a headless CMS, allowing you to:
- Add detailed explanations about how to use this tool
- Include examples and use cases
- Provide tips and best practices
- Add FAQs and troubleshooting guides
- Update content without touching the code
How to Use
Step-by-step instructions for using the Git Commands Cheat Sheet will appear here. This content will be fully customizable through the admin panel.
Features
Key features and benefits of this tool will be listed here. All content is editable via the CMS.