Git Branching Quick Reference Cheat Sheet
Key Takeaways
- โKeep this Git Branching reference bookmarked for quick daily lookups
- โFocus on memorizing the essential commands first before advancing
- โCombine commands with pipes and redirection for powerful workflows
- โUse tab completion and aliases to speed up common operations
Branch Creation and Navigation
git branch <name> # Create branch
git switch <name> # Switch branch
git checkout -b <name> # Create + switch
git switch -c <name> # Create + switch (new)
git branch # List local branches
git branch -a # List all branches
git branch -r # List remote branches
git branch -vv # Branches with trackingBranch Management
git branch -d <name> # Delete (safe)
git branch -D <name> # Delete (force)
git branch -m <old> <new> # Rename branch
git branch --merged # Show merged branches
git branch --no-merged # Show unmerged branches
git push origin --delete <b> # Delete remote branch
git fetch --prune # Clean stale refsIs Your Codebase Production-Ready? Find Out Before Your Users Do.
Upload your repo. Get a full QA audit: bugs, security, performance, best practices.
Audit My ProjectRemote Branch Operations
git push -u origin <branch> # Push + set upstream
git checkout --track origin/<b> # Track remote branch
git push origin <local>:<remote> # Push with rename
git fetch origin <branch> # Fetch specific branch
git pull origin <branch> # Pull specific branch
git branch --set-upstream-to=origin/<b> <local>Branch Comparison
git log main..<branch> # Commits in branch not in main
git log <branch>..main # Commits in main not in branch
git diff main...<branch> # Changes introduced by branch
git diff <branch1> <branch2> # Diff between two branches
git log --left-right main...<b> # Show which side each commit is onAdvanced Branch Patterns
git worktree add ../path <branch> # Checkout branch in new dir
git worktree list # List worktrees
git stash branch <name> # Create branch from stash
git checkout -b <b> <start> # Branch from specific commit
git branch --contains <commit> # Find branches with commit
git branch --sort=-committerdate # Sort by recent activityUnlock Unlimited QA Audits for $15.99/mo
Free: 5 audits/day. Pro $15.99/mo: 50/day + 250 pages. Pro Max $99/mo: unlimited audits, 10K pages, API access.
See PlansFrequently Asked Questions
How should I use this Git Branching cheat sheet?
Bookmark this page and reference it when you need exact syntax for Git Branching commands. Focus on memorizing the commands in the essentials section first, as you will use those daily. As specific situations arise, consult the advanced sections. Over time, the most-used commands will become muscle memory.
What are the most important Git Branching commands to memorize?
Start with the five to ten commands you use most frequently in your daily workflow. For most developers, these include the basic operations covered in the first section of this cheat sheet. Once those are automatic, gradually add intermediate commands. Do not try to memorize everything at once โ learn commands as you need them.
Does this cheat sheet cover the latest Git Branching version?
Yes, this cheat sheet is updated for 2026 and covers the latest stable version. We verify all commands against current releases and update the page when significant changes occur. If you encounter a command that does not work, check your installed version and update if necessary.
Can I print this Git Branching cheat sheet?
Yes, this page is designed to be print-friendly. Use your browser's print function and select the content area. Consider printing just the sections most relevant to your current work and keeping them near your workspace as a quick reference until the commands become second nature.
Where can I practice these Git Branching commands?
Set up a test environment where you can experiment safely without affecting real projects. For command-line tools, create a practice directory with sample files. For Docker, use throwaway containers. For Git, create a test repository. Practice in a safe environment builds confidence and muscle memory without risk.
Related Articles
Unlock Unlimited QA Audits for $15.99/mo
Free: 5 audits/day. Pro $15.99/mo: 50/day + 250 pages. Pro Max $99/mo: unlimited audits, 10K pages, API access.
See PlansBliniBot is an AI assistant that automates repetitive browser tasks and workflows. Try it free โ
Is your site built to last?
Run a free QA audit and get your Site Health Score in seconds.
Check Your Site FreeNo signup required