Combining Work with merge
Last lesson you opened a branch and tried an idea off to the side, without risking main. But an experiment that stays alone on its own branch helps no one — at some point you need to bring the work back home. That's where git merge comes in: a single command that combines another branch into the bra
merge is like combining two travel journals into one volume. If only one of you wrote since you parted — you just attach those pages to the end (fast-forward). If both of you wrote in parallel — you add a new page that says 'we joined here' (a merge commit).
- git merge
- Combines another branch into the branch you're currently standing on. It's how you bring work from an experiment branch back into main.
- Fast-forward
- A merge with no new commit: if the branch you merge into didn't move since the branch opened, Git just slides the pointer forward. History stays one straight line.
- Merge commit
- A special commit with two parents, marking the point where two branches joined. Created when both main and the branch advanced in parallel.
- Diverged history
- A state where two branches share a common starting point and then each advanced separately — a 'fork' in the graph that needs joining.