Search code examples
gitgitlabgit-mergeconflictgit-merge-conflict

Git merging more commit than it should


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


Solution

  • 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