merging and rebasing

merging and rebasing

combining branches — merge, rebase, cherry-pick

merging and rebasing

copy
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.

copy
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.

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

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

copy
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.