Merging Branches
Merging integrates the history of one branch into another. A fast-forward merge occurs when the target branch has not diverged and can simply move its reference forward. When branches have diverged, Git may create a merge commit that records both parent histories.
Merge Integration
Merge a Feature
git switch main
git merge feature/login
git log --oneline --graph --decorate --all💡 The feature branch is merged into the currently checked-out
main branch. Git chooses an appropriate merge strategy based on the relationship between the branches.Key Takeaways
- A merge preserves the original branch histories.
- Fast-forward merging does not create an additional merge commit.
- A merge commit can have two or more parents.
Knowledge Check
What is a fast-forward merge?