Branch management, merging, and conflict resolution
| Command | Description |
|---|---|
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) |
| Command | Description |
|---|---|
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 |
| Command | Description |
|---|---|
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 |
| Command | Description |
|---|---|
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 |
| Command | Description |
|---|---|
git branch -d <name> | Delete merged branch |
git branch -D <name> | Force delete branch |
git push origin --delete <branch> | Delete remote branch |