Skip to content

Try our new Crash Courses!

Buy one of our new Crash Courses, now hosted on Podia.

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 Reference > Git Intermediate