1

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.

4
  • if branch-2 is based off of branch-1 and no further commits have been done on branch-1 since, there should be no conflicts between the two. Commented Aug 3, 2017 at 10:15
  • Okay. So that means that branch-1 will basically build on the changes from branch 2 if branch 2 is a few commits ahead of branch 1? Commented Aug 3, 2017 at 10:18
  • That means that if you merge b2 into b1, that will be a fast-forward merge (b1 will only be advanced to the commit pointed to by b2) Commented Aug 3, 2017 at 10:20
  • Okay thanks. That helps me to understand it better. Commented Aug 3, 2017 at 10:23

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks @VictorLopez

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.