git merge <branchname1> <branchname2>

Merge a branch into a target branch

This command is used for combining the changes made in <branchname1> and <branchname2>.

It does this by creating a new commit which incorporates the changes of both branches. The changes from <branchname1> and <branchname2> are compared and if there are non-conflicting changes in the lines of the same files, the lines are merged together automatically.

In case of conflicts, it requires manual resolution.

Variations of this command include git merge --no-commit <branchname> which merges the branch but does not create a new commit, and git merge --squash <branchname> which allows you to combine commits from the merged branch into one commit on the current branch.

Manual page
git merge
Related commands

Welcome to GitExamples!

Sign in to enable bookmarking, reminders, progress-tracking and more...