0

I am using gitlab. My query is regarding Pull Requests. I created a "feature" branch. At end, we create a pull request to some "dev" branch. Now the problem is: there will be 'n' number of pull requests going on for the same 'dev' branch. So, now if anyone merged some other person merge request into 'dev' branch, then again I have to take latest pull, fix conflicts and then have to again commit and push, so that my latest gets added into my pull request.

This seems to be bit blocker, especially if developer who take leave for couple of days and his merge request will never gonna gets merged as his pull request always shows as "you commit behind some number of commits".

Another problem is: The one who has been assigned to merge that pull request, cannot do it as he depends on a developer until he merge again with latest commit.

So, any solution for this? or is this everyone doing the same thing as mentioned above?

In short: am facing this issue: gitlab Request to merge branch-A into develop (3 commits behind) should I worry?

john
  • 925
  • 1
  • 12
  • 20
  • Is this causing a practical problem for you? If a branch is a little behind the main branch, it can still be merged unless you have an option enabled that forbids that. Conflicts should not be that common in most repositories. – bk2204 Dec 10 '20 at 02:22
  • @bk2204 yes, its a problem for both approver and a developer too. As approver could not able to merge it due to becoz of "behind commits" and a developer have to always keep updating that MR everytime when any new commits got added into dev branch. As you said, we can able to still merge, but is this really allowed and what option is that to forbid? and incase if merged, what to do incase if it get conflicts after merging MR? – john Dec 10 '20 at 03:54
  • If you are able to merge, then just do so. It's not a big deal that it's behind by a few commits, since this happens literally all the time on major projects. If there are conflicts, merging won't be possible. – bk2204 Dec 10 '20 at 23:47
  • @bk2204 Incase of conflicts, what do you do? (assume if you are a approver) – john Dec 11 '20 at 04:01
  • @bk2204 I had a query to your answer.. could you pls check.. – john Dec 12 '20 at 07:10

1 Answers1

1

In general, it's fine to merge a branch if it's a few commits behind. This is very common on any project of reasonable size, and the merge is generally going to be identical to when it's rebased and then merged. Git is designed to handle this case simply and robustly.

It is possible that some projects require all branches to be up to date before merging, but if your project doesn't require this, then there's no reason to worry. The reason this output exists is to give you an idea of how much the branches have diverged. If they've diverged greatly, then a rebase could be warranted because you're more likely to have a logical conflict that isn't a textual conflict. But if it's just a few commits, I wouldn't stress out.

It won't be possible to merge if there are conflicts. In such a case, typically you ask the original submitter to rebase because they wrote the code and are going to be most familiar with fixing the conflicts. Once that's done, you can merge.

bk2204
  • 64,793
  • 6
  • 84
  • 100
  • If we directly merge by ignoring "behind commits" warning, then assume Incase of conflict, all conflict changes gets merged into dev branch, and then whoever takes latest from dev, they get all conflicted files, right? – john Dec 12 '20 at 07:10
  • 1
    No. It won't be possible to merge if there are conflicts. GitLab shouldn't let you. – bk2204 Dec 12 '20 at 16:27
  • okay fine. one more thing: in Merge Request., does any approver directly merge (even if it shows as like 2 commits behind, for eg: https://miro.medium.com/max/1642/1*cgLb6Th7ZCha01oupEG4JA.png) or do they ask developer merge dev into feature and push to resolve above issue? – john Dec 13 '20 at 06:20
  • 1
    If there are conflicts, the developer should rebase onto the main branch and force push into the same branch, which will update the MR. If there aren't conflicts, then anyone should be able to merge if they have proper permissions. – bk2204 Dec 13 '20 at 18:44