Chapter 6 of 14All chapters
Chapter 6 of 14
Merging
Bringing a branch back into the line.
How a merge works
git merge feature takes the work on that branch and joins it into the one you are on. When nothing else has moved, Git fast forwards the label instead of making a merge commit.
- Merge from the branch you want to keep: switch to main first, then merge.
- git merge --no-ff forces a merge commit when you want the branch visible in history.
Rebase as the alternative
git rebase replays your commits on top of another branch, producing a straight history with no merge commit. Never rebase commits that other people have already pulled.