Skip to content
ZeroServer.tools

Git Cheat Sheet

Essential Git commands organized by workflow stage

Setup & Config

git config --global user.name "Name"
git config --global user.email "email"
git config --list
git init
git clone <url>
git clone <url> --depth 1

Staging & Committing

git status
git add <file>
git add .
git add -p
git commit -m "message"
git commit --amend
git diff
git diff --staged
git reset HEAD <file>
git restore <file>

Branching & Merging

git branch
git branch -a
git branch <name>
git checkout <branch>
git checkout -b <branch>
git switch -c <branch>
git merge <branch>
git rebase <branch>
git branch -d <branch>
git branch -D <branch>

Remote

git remote -v
git remote add origin <url>
git fetch
git pull
git pull --rebase
git push origin <branch>
git push -u origin <branch>
git push --force-with-lease

Stash

git stash
git stash pop
git stash list
git stash apply stash@{n}
git stash drop stash@{n}
git stash push -m "label"

Log & History

git log
git log --oneline
git log --oneline --graph --all
git log -p
git blame <file>
git show <commit>
git log --author="Name"

Undoing & Fixing

git revert <commit>
git reset --soft HEAD~1
git reset --mixed HEAD~1
git reset --hard HEAD~1
git clean -fd
git cherry-pick <commit>
git reflog

Tags

git tag v1.0.0
git tag -a v1.0.0 -m "msg"
git push origin --tags
git tag -d v1.0.0

How to use this Git cheat sheet

This reference covers the most important Git commands every developer uses daily. It is organized by workflow phase — from initial setup through branching, committing, working with remotes, and undoing mistakes. Use the search box to quickly find any command by name or description. Click the copy icon next to any command to copy it to the clipboard. For deeper understanding of any command, run git help <command> in your terminal.

Private & free — this tool runs entirely in your browser.

Recommended: IndieKit Ship your Next.js startup in days.affiliate

Related Developer Utilities tools