Skip to content

Help us create more tutorials! Make a donation using the Donate button or become a member using the button below to hide this banner and track your progress.

Merge branches – Git

Summary

To merge branches, first switch to the branch that you’re merging into by entering the following command into your terminal:

git checkout branch-to-merge-into

Then, enter the following command to merge a different branch into it:

git merge branch-with-changes

Details

Here’s an example of how you would merge a topic branch into master.

git checkout master

git merge topic-branch

Exercises

Run the following commands:

git checkout master

git merge dev-branch

If your original branch is called main, use the following commands instead:

git checkout main

git merge dev-branch

References

Basic Branching and Merging from the Pro Git book

Back to: Git Course > Git Intermediate