Git 2 cheatsheet
Git 2: Branches
9 common Git 2 tasks.
Create and switch to a branch
Create a new branch from the current commit and switch to it.
git switch -c feature/login
Delete a merged branch
Delete a local branch that has been merged. Git refuses if it has unmerged work.
git branch -d feature/login
Delete an unmerged branch
Delete a local branch even if its commits are not merged.
git branch -D feature/login
Caution: Unmerged commits become hard to find. You can usually recover them with git reflog.
Delete a remote branch
Remove a branch from the remote.
git push origin --delete feature/login
Caution: The branch disappears for everyone who uses the remote. Check that nobody needs it first.
Rebase onto another branch
Replay your commits on top of main.
git rebase main
Caution: Rebasing rewrites commits. Don't rebase branches other people have pulled.