Site Tools


wiki:git-merging

Table of Contents

Git Merging

Merging combines two branches. Switch to the target branch (usually main) and run git merge <feature-branch> to integrate changes. If git can automatically merge without conflicts, it creates a merge commit. If there are conflicts, you must resolve them manually before committing.

$ git checkout main          # switch to target branch
$ git merge feature-branch   # merge feature-branch into main
$ git merge --abort         # cancel a merge if conflicts arise

A merge commit is a special commit with two parents: the old tip of main and the tip of the feature branch. It represents the point where two lines of development converged. Merge commits preserve history and make it clear when features were integrated, but they can clutter the log on frequently-merged branches.

wiki/git-merging.md · Last modified: (external edit)