Skip to Content
sudocs

Merging and rebasing

combining branches — merge, rebase, cherry-pick

merging and rebasing

git merge feature/my-thing

merges the target branch into the current one. creates a merge commit. fine for most cases, leaves the history a bit messy.

git rebase main

replays your commits on top of main. keeps history linear. good for keeping feature branches up to date before opening a PR.

# typical rebase flow
git switch feature/my-thing
git fetch origin
git rebase origin/main
git rebase --abort

bails out of a rebase mid-way if things go sideways. puts you back where you started.

git cherry-pick abc1234

applies a single commit from another branch onto your current branch. useful when you just need one specific fix without merging the whole branch.

On this page