What Is a Git Cheatsheet?
A Git cheatsheet is a quick-reference guide that lists the most commonly used Git commands organized by category. Git is the world's most popular distributed version control system, used by millions of developers to track changes, collaborate on code, and manage project history. With dozens of commands and hundreds of options, even experienced developers benefit from having a concise reference at hand. This cheatsheet covers everything from basic setup and staging to advanced workflows like interactive rebasing, stash management, and history inspection.
How to Use This Git Cheatsheet
- 1Browse commands organized into categories: Setup, Staging, Branching, Remote, Stash, Undo, Inspection, and Tags.
- 2Use the search field to filter commands by keyword — type 'rebase', 'stash', 'reset', or any part of a command or description.
- 3Each command shows the syntax, a short description, and common flags or options you can use.
- 4Click the copy button next to any command to copy it to your clipboard for immediate use in your terminal.
- 5Use the flags listed under each command to discover useful variations you might not know about.
Common Use Cases
Daily Development Workflow
Quickly look up commands for committing, branching, and pushing code during your daily development workflow without leaving your browser.
Learning Git
New to Git? Browse the organized categories to discover commands and understand what each one does, complete with common flags and options.
Resolving Merge Conflicts
Find the right commands for rebasing, merging, resetting, and reverting when you need to resolve conflicts or undo mistakes.
Code Review & Inspection
Use inspection commands like git log, git blame, and git show to review commit history, understand changes, and trace code authorship.
Frequently asked questions
What is the difference between git merge and git rebase?
Both integrate changes from one branch into another. 'git merge' creates a merge commit preserving the full history of both branches. 'git rebase' replays your commits on top of the target branch, producing a linear history. Merge is safer for shared branches; rebase is cleaner for feature branches before merging.
How do I undo the last commit?
Use 'git reset --soft HEAD~1' to undo the commit but keep changes staged. Use 'git reset --mixed HEAD~1' to undo the commit and unstage changes. Use 'git reset --hard HEAD~1' to undo the commit and discard all changes. If the commit is already pushed, use 'git revert' instead to create a safe undo commit.
What is the difference between git fetch and git pull?
'git fetch' downloads new data from a remote repository but does not integrate it into your working branch. 'git pull' is essentially 'git fetch' followed by 'git merge' — it fetches and immediately integrates the changes. Use fetch when you want to review changes before merging.