init: git merge
In this video we'll learn how to use git merge
.
After making your changes on a branch, you'll often want to bring those changes into another branch.
In this case, we'll want to bring the changes on our new-branch back into the master branch.
Let's demonstrate this by checking out our new-branch and making a few commits.
If I run git log --oneline --graph --decorate --all
I'll see these two commits are ahead of master.
To get them on the master branch, first I'll switch back to the master branch by running:
git checkout master
Now, I'll merge the commits from the new-branch into master by running:
get merge new-branch
Notice I pass git merge
the branch name with the changes while I'm on the branch I want to merge into.
If I run git log
again, we'll see that new-branch and master are all in line and contain the same commits.
Git is pretty smart when merging in your changes, but sometimes a conflict can occur if the branches commit histories don't match or overlapping changes were made to the same file.
We'll learn how to handle these conflicts in Master: git merge.