-1

I use git + Jenkins + gerrit. And how to automatically resolve merge conflicts? I always see status in webui "Submitted, Merge Pending".

I tried all submit type: Fast-Forward, Merge if necessary, Rebase if necessary, Always Merge, Cherry Pick. But no one doesn't solve this problem. I always see "Submitted, Merge Pending"

1 Answers1

2

To a certain extent you have automatic merge conflict resolution, that is what git merge does. It just doesn't always work.

When two people change the same line in a file in different ways, git has no idea how to determine which change to do or how to combine the changes. So you need to provide it direction as to the correct state of the file. This really is a good thing.

You really don't want to have automatic merge resolution on all merges. Having this runs the risk of a merge being done incorrectly and your build being incredibly broken because of it. When you have conflicts, you want a set of human eyes looking at the changes and deciding what is the correct course of action.

Your actual problem is one of branching and management. You want to set up your branches and merges so minimize the number of conflicts that occur. Try to avoid having multiple people working in the same area at the same time. If that isn't possible, put them on the same branch so that they are sharing the code and getting each others changes regularly. Then have one person rebase and submit the change to gerrit and jenkins.

Schleis
  • 41,516
  • 7
  • 68
  • 87
  • I have one problem with gerrit + jenkins. For example: I wrote the code with one error, commited and pushed it.Then jenkins built my project, said that my build-NOT-Ok and gerrit abandoned this patch set and I received e-mail about this. Then I wrote the fix for this error? commited and pushed it. But "Submitted, Merge Pending". How to resolve this problem? – Юрий Маслов May 08 '15 at 13:20
  • I think you typically need to do a 'git commit --amend' for subsequent bugfixes for the changes to be picked-up by gerrit as part of the review. – MrWonderful Oct 18 '18 at 08:08