Skip to main content

Git Cheatsheet Interactive

Search and filter 50+ essential Git commands. Click any command to copy it instantly. Organized by category: setup, staging, branches, remotes, history, and more. Free, no sign-up.

✓ 60K+ developers trust DevPlaybook ✓ Runs 100% in your browser ✓ One-click copy
56 commands
Setup
git config --global user.name "Name"Set global username
git config --global user.email "[email protected]"Set global email
git config --listShow all config settings
git initInitialize a new repo in current directory
git clone <url>Clone a remote repository
Staging & Committing
git statusShow working tree status
git add <file>Stage a specific file
git add .Stage all changes
git add -pInteractively stage hunks
git commit -m "message"Commit with a message
git commit --amendAmend the last commit
git diffShow unstaged changes
git diff --stagedShow staged changes
git stashStash current changes
git stash popApply stashed changes
git stash listList all stashes
Branches
git branchList local branches
git branch -aList all branches (local + remote)
git branch <name>Create a new branch
git checkout <branch>Switch to a branch
git checkout -b <branch>Create and switch to branch
git switch <branch>Switch branches (modern syntax)
git switch -c <branch>Create and switch (modern syntax)
git branch -d <branch>Delete a merged branch
git branch -D <branch>Force delete a branch
git merge <branch>Merge a branch into current
git rebase <branch>Rebase onto another branch
git rebase -i HEAD~3Interactive rebase (last 3 commits)
Remote
git remote -vList remote connections
git remote add origin <url>Add a remote named origin
git fetchFetch all remotes
git fetch originFetch from origin
git pullFetch and merge from remote
git pull --rebaseFetch and rebase from remote
git push origin <branch>Push branch to remote
git push -u origin <branch>Push and set upstream
git push --force-with-leaseSafe force push
History
git logShow commit history
git log --onelineCompact one-line log
git log --oneline --graphVisual branch graph
git log -pShow patches in log
git show <commit>Show a commit details
git blame <file>Show who changed each line
git log --author="Name"Filter log by author
git log --since="2 weeks ago"Filter log by date
Undo & Reset
git restore <file>Discard working dir changes
git restore --staged <file>Unstage a file
git reset HEAD~1Undo last commit (keep changes)
git reset --hard HEAD~1Undo last commit (discard changes)
git revert <commit>Create a revert commit
git clean -fdRemove untracked files/dirs
Tags
git tagList all tags
git tag v1.0.0Create lightweight tag
git tag -a v1.0.0 -m "Release"Create annotated tag
git push origin --tagsPush all tags to remote
git tag -d v1.0.0Delete a local tag

Frequently Asked Questions

What is the difference between git fetch and git pull?▼

git fetch downloads changes from the remote but does NOT merge them into your working branch. git pull is essentially git fetch + git merge — it downloads and integrates remote changes. Use fetch when you want to review changes before merging.

How do I undo the last commit without losing changes?▼

Use 'git reset HEAD~1'. This moves the branch pointer back one commit but keeps your files unchanged (staged changes become unstaged). To also unstage, use 'git reset HEAD~1 --mixed'. To discard changes entirely, use 'git reset --hard HEAD~1'.

What is git stash used for?▼

git stash temporarily saves your uncommitted changes so you can work on something else. Use 'git stash' to save and 'git stash pop' to restore. This is useful when you need to switch branches mid-task without committing unfinished work.

What is the difference between git merge and git rebase?▼

git merge creates a new 'merge commit' that joins two branches while preserving history. git rebase rewrites history by moving your commits on top of another branch, creating a linear history. Rebase is cleaner but rewrites commits — never rebase shared/public branches.

Share this tool: X / Twitter LinkedIn
✓ 60,000+ developers use DevPlaybook ★★★★★ 4.8 / 5 on Gumroad ✓ MIT licensed · Instant download ✓ No login required

Related Products

on Gumroad

You Might Also Need

More Free Tools

Enjoying this tool? Get more like it.

Weekly developer tool guides, productivity playbooks & AI tricks. Free. No spam.

DevPlaybook Pro 7 days free

Unlock AI-Powered Dev Tools

  • ⚡ AI Code Review, Doc Generator & SQL Builder
  • ⚡ All premium templates & early access
  • ⚡ Member discounts on Gumroad products
Start Free Trial →

$9/mo after trial · Cancel anytime

Want the full toolkit?

Get DevPlaybook Pro

Every template, guide, boilerplate, and automation script in one bundle. 13 premium products — grab them all at once and save big.

$79
$241 separately Save $162 (67% off)
Get DevPlaybook Pro — $79 →

MIT licensed · Instant download · No subscription

See what's included → Browse all deals →