Merging Branches Back

Merging

When a feature is done, you merge it back into main. You merge into the branch you're currently on.

$ git switch main
$ git merge feature-login
Updating 9f8e7d6..a1b2c3d
Fast-forward
 login.js | 20 ++++++++++

Two kinds of merge:

TypeWhenResult
Fast-forwardmain hasn't moved since you branchedPointer just moves forward, no merge commit
Three-way mergeBoth branches have new commitsCreates a merge commit joining the histories
Tip: The typical flow: git switch maingit pull (get latest) → git merge feature. Always merge into the target branch while standing on it.

After merging, clean up: git branch -d feature-login.