Back to Cheatsheets
Terminal & Git

Git Branching

Branch management, merging, and conflict resolution

Branch Basics

7 items
CommandDescription
git branch
List local branches
git branch -a
List all branches (including remote)
git branch <name>
Create new branch
git checkout <branch>
Switch to branch
git checkout -b <name>
Create and switch to branch
git switch <branch>
Switch branch (newer syntax)
git switch -c <name>
Create and switch (newer syntax)

Merging

3 items
CommandDescription
git merge <branch>
Merge branch into current
git merge --no-ff <branch>
Merge with commit (no fast-forward)
git merge --abort
Abort merge in progress

Rebasing

4 items
CommandDescription
git rebase <branch>
Rebase current branch onto another
git rebase -i HEAD~3
Interactive rebase last 3 commits
git rebase --continue
Continue after resolving conflicts
git rebase --abort
Abort rebase

Stashing

5 items
CommandDescription
git stash
Stash current changes
git stash pop
Apply and remove last stash
git stash list
List all stashes
git stash apply stash@{0}
Apply specific stash
git stash drop
Remove last stash

Cleanup

3 items
CommandDescription
git branch -d <name>
Delete merged branch
git branch -D <name>
Force delete branch
git push origin --delete <branch>
Delete remote branch