0

I'm rather unfamiliar with git (mostly using classic commands like checkout, push, pull)

Here is my gitflow, I've got 2 branch Master and Develop. I'm working on Develop and then creating merge request from Develop to Master.

I've done it last week and everything worked perfectly, in the mean time I've made 3 more commits (on Develop) and now when I create a merge request it's pulling 5 commits (the 3 I did and the 2 of the last merge request) The issue is that it's creating conflict between my files.

Why when I'm doing a merge request is it trying to merge commits that's already in the branch ? and How can I resolve this ?

Edit: I just saw this message on the merge request "The source branch is N commits behind the target branch"

Edit2 (step by step actions):

  1. Master & Develop branch are identical
  2. Checkout on develop and working on it, resulting in 2 commits (commit A & B)
  3. Merge request source: Develop into target: Master
  4. Both branch are identical
  5. Checkout on develop and working on it, resulting in 3 commits (commit C, D & E)
  6. Attempt merge request source: Develop into target: Master (resulting in conflicts)

/!\ Issue where 5 commits (A to E) are trying to be merged into Master

Biscuit
  • 3,364
  • 3
  • 15
  • 33
  • you need to describe step by step what you really did. – Serge Oct 31 '19 at 16:28
  • I just edited my post, if you need more info just ask – Biscuit Oct 31 '19 at 16:34
  • The message about '5 commits behind' is related to a **remote** repository. According to your description you did everything it the **local** repository. The commits in a **local** repository *differ* from the **remote** one until you do `pull` or `push`. So, please list all the git commands which you used for every step. It looks like you mix two different things. There is no way to get conflicts in your described flow unless the master branch is also changed. – Serge Oct 31 '19 at 17:17
  • This might be helpful: https://stackoverflow.com/questions/161813/how-to-resolve-merge-conflicts-in-git – LuVu Nov 01 '19 at 12:19

2 Answers2

0

As per the above statement, the master is more stable and least updated and develop is a less stable and most updated branch.(which is ideal case)

In this case when push commits to Develop branch and you should raise a pull request from Develop to master (try to use rebase while merge pull request that won't add extra commit). then, in this case, there will be no conflict if no other contributer has merged changes to master, if it is then it might conflict and need to resolve and push to Develop branch and your Pull Request will updated and conflicts will gone.

There might be another case that your Develop branch is default branch(which is behaving as like master) and you have created master branch (which is behaving as Develop)later on in this case if you push changes to Develop Branch then when try to update master branch through or without PR, then it will ask you to resolve conflict in both branch and if you try to do so it will add same commits again to branch.

0

In the end, the issue was when I did the first merge request via Gitlab, it created a commit by the user who approved it and I didn't have this commit on develop.

My solution is to merge Master into Develop to fix the conflicts and then merge Develop into Master.

The source was simple conflict issue: How to resolve merge conflicts in Git

Biscuit
  • 3,364
  • 3
  • 15
  • 33