Git cheatsheet

git init
Create a new repository in the current directory.
git clone <url>
Copy a remote repository to your machine.
git status
Show changed, staged and untracked files.
git add <file>
Stage a file for the next commit.
git add -A
Stage all changes, including deletions.
git commit -m "msg"
Commit staged changes with a message.
git commit --amend
Change the most recent commit (message or contents).
git push
Send local commits to the remote.
git push -u origin <branch>
Push a new branch and set it to track the remote.
git pull
Fetch and merge remote changes into the current branch.
git fetch
Download remote changes without merging.
git branch
List local branches.
git branch <name>
Create a new branch.
git checkout <branch>
Switch to a branch.
git checkout -b <branch>
Create and switch to a new branch.
git switch <branch>
Modern equivalent of checkout for switching branches.
git merge <branch>
Merge another branch into the current one.
git rebase <branch>
Replay current branch's commits on top of another branch.
git log --oneline
Compact commit history, one line each.
git log --graph --all
Visualize branch history as a graph.
git diff
Show unstaged changes.
git diff --staged
Show staged changes not yet committed.
git stash
Temporarily shelve uncommitted changes.
git stash pop
Reapply the most recently stashed changes.
git reset --soft HEAD~1
Undo the last commit, keep changes staged.
git reset --hard HEAD~1
Undo the last commit and discard its changes.
git revert <commit>
Create a new commit that undoes a previous one.
git tag <name>
Tag the current commit (e.g. a release).
git remote -v
List remotes and their URLs.
git rm --cached <file>
Stop tracking a file without deleting it locally.
git cherry-pick <commit>
Apply a specific commit from another branch.
git blame <file>
Show who last changed each line of a file.

What is Git cheatsheet?

A searchable reference for the Git commands used in normal day-to-day work — branching, committing, undoing mistakes, and syncing with a remote — without digging through git --help.

How to use it

Search by command or by what you're trying to do (e.g. "undo", "stash", "branch").

Example

Searching "undo" surfaces git reset --soft HEAD~1, git revert, and git commit --amend.