Git Merge
What
A Merge is the process of combining two independent lines of development (branches) back together. It integrates the commit history and file changes from a target feature branch into a base branch.
How
To perform a merge, switch to the branch you want to receive the changes (the base branch) and run git merge followed by the name of the branch containing the changes:
# Switch to the receiving branch
git switch main
# Merge the target feature branch into the current branch
git merge feature_branch
You can view a visual, branch-separated ASCII graph of your commit history to verify how branches diverge and connect:
git log --oneline --graph --all
Why
Branches are designed to let you safely isolate work so that experimental or half-finished code doesn’t pollute the stable codebase. However, once a feature or bug fix is completed and verified, merging is the mechanism that reunites these independent branches, bringing those valuable changes back into the central production line for shipment.
Summary
Use git merge <branch_name> while standing on your receiving branch to combine historical lines of code development back together.