Reputation: 45
I am a little bit confused as to how a branch needs to be merged once work is completed.
So I have created a repo which has the following: I've based each branch according to issue/feature.
Master
Development
branch-1 - jira issue 1
branch-2 - jira issue 2
branch-3 - jira issue 3
branch-4 - jira issue 4
Issue 1 was created off of Development branch. Once I've completed work in the first branch I then created branch 2 while still being on branch-1 like so.
git checkout -b branch-2
I started working on branch-2 and then completed the work needed to be done on that issue.
But I am sitting with a problem where branch-1 has eg. 8 commits and branch-2 has 15 commits. I'm guessing there will be merge conflicts here. So if I were to merge these branches once they've been reviewed. How do I proceed? Help will be great. Thanks in advance.
Upvotes: 1
Views: 50
Reputation: 817
Git is very friendly to conflicts. With a little patience you will understand it.
The procedure is like this (On branch2):
git checkout branch1
git merge branch2
Git will show you the conflicts (if you have them). An example of conflict will be like this:
<<<<<<< HEAD
this code is old
=======
this is my new code
>>>>>>> branch1
You could choose between bot lines.
Don't be afraid, conflicts are very common and you should learn to understand and fix them.
Upvotes: 1