git init Initialize a new git repository
git clone <url> Clone a remote repository
git config --global user.name "Name" Set your global username
git config --global user.email "email" Set your global email
git config --list Show all configuration settings
git remote add origin <url> Add a remote repository
git remote -v List remote repositories
git branch List local branches
git branch -a List all branches (local + remote)
git branch <name> Create a new branch
git branch -d <name> Delete a branch (safe)
git branch -D <name> Force delete a branch
git branch -m <old> <new> Rename a branch
git checkout <branch> Switch to a branch
git checkout -b <name> Create and switch to new branch
git switch <branch> Switch to a branch (modern)
git switch -c <name> Create and switch (modern)
git status Show working tree status
git add <file> Stage a specific file
git add . Stage all changes
git add -p Stage changes interactively (by hunk)
git commit -m "message" Commit staged changes with message
git commit -am "message" Stage tracked files and commit
git commit --amend Amend the last commit
git diff Show unstaged changes
git diff --staged Show staged changes
git diff <branch1> <branch2> Compare two branches
git push Push commits to remote
git push -u origin <branch> Push and set upstream branch
git push --force Force push (destructive!)
git pull Fetch and merge remote changes
git pull --rebase Fetch and rebase instead of merge
git fetch Download remote changes without merging
git fetch --prune Fetch and remove deleted remote branches
git push origin --delete <branch> Delete a remote branch
git stash Stash current changes
git stash push -m "message" Stash with a description
git stash list List all stashes
git stash pop Apply and remove latest stash
git stash apply Apply latest stash without removing
git stash drop Delete latest stash
git stash clear Delete all stashes
git log Show commit history
git log --oneline Show compact commit history
git log --graph --oneline Show commit graph
git log -n 5 Show last 5 commits
git log --author="name" Filter commits by author
git log -- <file> Show commits for a specific file
git blame <file> Show who changed each line
git show <commit> Show details of a commit
git merge <branch> Merge a branch into current
git merge --no-ff <branch> Merge with a merge commit (no fast-forward)
git merge --abort Abort a merge in progress
git rebase <branch> Rebase current branch onto another
git rebase --abort Abort a rebase in progress
git cherry-pick <commit> Apply a specific commit to current branch
git restore <file> Discard changes in working directory
git restore --staged <file> Unstage a file
git reset HEAD~1 Undo last commit, keep changes staged
git reset --hard HEAD~1 Undo last commit and discard changes
git revert <commit> Create a new commit that undoes a commit
git clean -fd Remove untracked files and directories
git reflog Show history of HEAD changes (recovery)
git tag List all tags
git tag <name> Create a lightweight tag
git tag -a <name> -m "msg" Create an annotated tag
git push --tags Push all tags to remote
git tag -d <name> Delete a local tag
Git Commands Cheatsheet
A comprehensive, searchable reference of the most useful git commands. Filter by category (setup, branch, commit, remote, stash, log, merge, undo, tags) or search by keyword. Click to copy any command.
About this cheatsheet
This git cheatsheet covers the most common git operations organized by workflow category. Perfect as a quick reference while coding.
- 65+ git commands with descriptions
- Filter by category (Setup, Branch, Commit, Remote, Stash, Log, Merge, Undo, Tags)
- Full-text search across commands and descriptions
- One-click copy to clipboard
- Works offline — all data is in the page
100% free. No signup required. No data collected or sent anywhere.