Merging
Merging
Two-way easy combination of two branches. The simplest conceptually, but other methods may be more efficient in some merge conflicts. Once you do a merge, you can't do a rebase later on.
# SWITCH TO TARGET BRANCH FIRST
git merge OTHER_BRANCH
Rebase
Ideal when you want to catch up your branch with main, without a merge. It puts the latest changes on the upstream behind your latest commits.
# SWITCH TO BRANCH TO REBASE INTO
git rebase REBASE_FROM_BRANCH
Cherry-Picking
When you want to copy one commit and paste it on another branch. You can do multiple commits in a row, but consider squashing first after a few.
# SWITCH TO BRANCH TO REBASE INTO
git cherry-pick COMMIT_HASH SECOND_HASH THIRD_HASH # and so on...