Git Branch Management Cheatsheet - Command Reference
Git branches are the core of team collaboration. All essential branch operation commands organized by Create & Switch, Merge & Rebase, Remote Branches, and Cleanup for managing multi-branch development workflows.
Back to Version ControlCreate & Switch 5
git branch feature/loginCreate a new branch
git checkout feature/loginSwitch to a branch
git checkout -b feature/loginCreate and switch to a new branch
git switch feature/loginSwitch to a branch (new command)
git switch -c feature/loginCreate and switch (new command)
Merge & Rebase 5
git merge feature/loginMerge branch into current branch
git merge --no-ff feature/loginForce create merge commit
git rebase mainRebase onto main branch
git rebase -i HEAD~3Interactive rebase of last 3 commits
git rebase --abortAbort rebase
Remote Branches 5
git push origin feature/loginPush branch to remote
git push -u origin feature/loginPush and set upstream tracking
git fetch originFetch remote updates
git pull origin feature/loginPull remote branch
git branch -rView remote branches
Delete & Cleanup 4
git branch -d feature/loginDelete merged branch
git branch -D feature/loginForce delete unmerged branch
git push origin --delete feature/loginDelete remote branch
git branch --mergedView merged branches
💡 Tips
- Both git switch and git checkout can switch branches, but switch is more focused on branch operations.
- rebase rewrites commit history — never rebase on shared branches that have been pushed.
- --no-ff merge preserves branch history, suitable for merging feature branches into main.
- git branch -vv shows tracking relationships between local and remote branches.
Official References
Commands are compiled from the official docs below. Click to verify the latest usage.
Maintained by LaoHand
Publicly updated on Jul 21, 2026, continuously proofread against official docs.
Found an error? Report it
Wrong command or description? Open an issue to help us fix it.
Found an error? Report it