Reputation: 39
There is the same file in my master
and in my welcome
branch. My master has nothing in the file but in my welcome there is a lot of things. What is going to happen when I put it all together?
Upvotes: 0
Views: 2581
Reputation: 76459
When you merge two branches, Git considers three locations: the two heads (in this case, the master
and welcome
branches) and the merge base, which is usually the point at which the branches forked.
When the merge happens, Git essentially looks at each side independently and compares it to the merge base, and determines what has changed. Git then applies both sets of changes in the result.
If one side is changed, and the other is not, Git incorporates the changes. So if at the point your branches were forked, the file was empty, then the result of the merge will have the contents of the file. If both sides are changes in the same area, a merge conflict will occur, and you'll need to resolve it. There isn't a way to avoid this, since Git doesn't know what you want done in this case.
If you want to test this out and see what will happen in your case, you can create a temporary branch off of master
and merge welcome
into it, and see what the result is like:
$ git checkout master
$ git checkout -b temp
$ git merge welcome
If you get into a conflicted state and don't want to continue, you can run git merge --abort
to return to where you were.
Upvotes: 2