# Git Branching and Merging

Create, switch, merge and rebase branches.

```bash
git branch                    # list local branches
git branch -a                 # include remote branches
git switch main               # switch branch
git switch -c feature/login   # create and switch
git branch -m new-name        # rename current branch
git merge feature/login       # merge into current branch
git merge --no-ff feature     # always create a merge commit
git merge --abort             # cancel a conflicted merge
git rebase main               # replay current branch on main
git rebase -i HEAD~3          # edit, squash or reorder last 3 commits
git rebase --continue         # after fixing a conflict
git rebase --abort            # cancel the rebase
git cherry-pick <sha>         # copy one commit here
git branch -d feature/login   # delete merged branch
git branch -D feature/login   # force delete
```
