Git Cheatsheet - Quick Command Reference & Memo
Free online Git cheatsheet with searchable commands organized by category. Quickly find Git commands for branching, merging, rebasing, stashing, resetting, and more.
Setup & Config
git initInitialize a new Git repository in the current directory
git clone <url>Clone a remote repository to your local machine
git config user.name "<name>"Set the author name for commits
git config user.email "<email>"Set the author email for commits
Staging & Commits
git add <file>Stage a file for the next commit
git commit -m "<message>"Create a commit with a message
git statusShow the working tree status
git diffShow unstaged changes
git logShow commit history
Branching & Merging
git branchList, create, or delete branches
git checkout <branch>Switch to a branch or restore files
git switch <branch>Switch to a branch (modern alternative to checkout)
git merge <branch>Merge a branch into the current branch
git rebase <branch>Reapply commits on top of another branch
Remote
git remote -vList remote repositories with URLs
git fetchDownload objects and refs from a remote
git pullFetch and integrate changes from a remote branch
git pushUpload local commits to a remote repository
Stash
git stashTemporarily save uncommitted changes
git stash popApply the most recent stash and remove it from the list
git stash listList all stashed changes
git stash dropRemove a specific stash entry
git stash applyApply a stash without removing it from the list
Undo & Reset
git reset <file>Unstage a file while preserving changes
git revert <commit>Create a new commit that undoes a previous commit
git restore <file>Discard changes in the working directory
git clean -fdRemove untracked files and directories
Inspection
git log --onelineShow compact commit history (one line per commit)
git log --graph --allVisualize branch history as a graph
git show <commit>Display details and diff of a specific commit
git blame <file>Show who last modified each line of a file
git reflogShow a log of all reference updates (useful for recovery)
git shortlog -snSummarize commit counts by author
Tags
git tag <name>Create a lightweight tag at the current commit
git tag -a <name> -m "<msg>"Create an annotated tag with a message
git tag -lList all tags
git push origin <tag>Push a specific tag to a remote
git tag -d <name>Delete a local tag
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
- Browse commands organized into categories: Setup, Staging, Branching, Remote, Stash, Undo, Inspection, and Tags.
- Use the search field to filter commands by keyword — type 'rebase', 'stash', 'reset', or any part of a command or description.
- Each command shows the syntax, a short description, and common flags or options you can use.
- Click the copy button next to any command to copy it to your clipboard for immediate use in your terminal.
- Use 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.