Hacker Read top | best | new | newcomments | leaders | about | bookmarklet login

When you have that many conflicts, it's often due to massive renames, or just code moves.

If you use git-mediate[1], you can re-apply those massive changes on the conflicted state, run git-mediate - and the conflicts get resolved.

For example: if you have 300 conflicts due to some massive rename, you can type in:

  git-search-replace.py[2] -f oldGlobalName///newGlobalName
  git-mediate -d
  Succcessfully resolved 377 conflicts and failed resolving 1 conflict.
  <1 remaining conflict shown as 2 diffs here representing the 2 changes>
[1] https://medium.com/@yairchu/how-git-mediate-made-me-stop-fea...

[2] https://github.com/da-x/git-search-replace



sort by: page size:

Issue #333: Simultaneous changes on different instances cause incorrect merge

https://github.com/presslabs/gitfs/issues/333

Seems like conflicts are being resolved poorly.


All merge conflicts. You can never resolve them as everything is screwed. Takes days to figure it out. You usually just delete the repo and start all over again from a working commit.

I spent some time with `git mergetool` to help resolve conflicts. It's hideous but it's better than staring at inline conflict markers

That's why I say "you have conflicts" and have them resolve the conflict before I do the review. GitHub, at least, correctly diffs against master after the conflicts are resolved so you don't see any of the merged code (if it's the same as on the master branch), only the actual changes.

Doesn't that solve the problem?


The thing is that git is not supposed to be smart when it comes to merging. https://wincent.com/blog/a-look-back-bram-cohen-vs-linus-tor...

At the end of the article: This is a clearly ambiguous merge and it simply wouldn’t be right for your version control system to try "resolving" it for you.

So the strategy is that if there is any doubt you have to manually fix conflicts. This is by design.


I'm confused by your comment. What kind of merge conflicts stop a project for days? And why would the solution to a merge conflict be to delete the repository and clone it again? Or are you being sarcastic?

That's why I showed an example of a rename. You write "manually fixed the conflict", where do you see that in the rename example?

You just re-apply either side of the changes in the conflict (Base->A, or Base->B) and the conflict is then detected as resolved. Reapplying (e.g: via automated rename) is much easier than what people typically mean by "manually resolving the conflict".

Also, as a pretty big productivity boost, it prints the conflicts in a way that lets many editors (sublime, emacs, etc) directly jump to conflicts, do the "git add" for you, etc. This converts your everyday editor into a powerful conflict resolution tool. Using the editing capabilities in most merge tools is tedious.


I think OP was talking about the issue in git itself that caused merges with mod 256 conflicts to go though and be committed, including all the merge error markers.

This happened on their live system (and would have happened on the command line for local git users), so OP (and incidentally, me too) was wondering how that wasn't noticed and wasn't causing support issues (it probably was which might have been another reason for this refactoring)


> So I edit the file, fix the trivial conflict, and git commit filename.

This is a bit vague, but I'm guessing you mean you open up the file in your text editor of choice and edit it directly.

What I do these days, probably originally prompted by exactly the sort of frustration you describe, is to run "git mergetool", which I happen to have configured to fire up emerge, but you can use any of a number of tools. Once I'm done, git is happy and I can just push. Initially I was a little grumpy about learning how to use emerge when before I just edited the file with all its <<<< and ==== and >>>> directly, but after learning the tool, I wish I'd been doing conflict resolution this way back when I used CVS and SVN. It's really much nicer and less error prone.

So, I hope that's a helpful hint. You're absolutely right about a lot of the unhelpful & unintuitive messages and commands.


I hope someone solves the merge conflict problem once and for all. Each time there’s a merge conflict the project stops for days as no one knows how to resolve them. In the end the solution always is to delete the git repository and clone it again.

I feel your pain. I have to resort to the web for gitlab which is what we use for source control for really big conflicts.

But as a team we try to get everyone to merge often and are very long lived branches as code smells. This keeps changes small and conflicts small.


Sounds more like a general technical github problem with merges.

I'm surprised that the author of this post would point out a rename conflict as something that "git gets right", in part because I'm relatively certain that git-merge-recursive did not exist when this this mailing list exchange occurred (I'm actually surprised that it was the default already in 2007) and git-merge-resolve would have done something completely different, treating `greeting` as deleted in both and `saludo` as added in left. There would be no conflicts and `saludo` would merrily be created, which seems like the wrong thing.

But I'm mostly surprised because rename conflicts are this transient thing. git-merge-recursive will detect a rename conflict, but you're hosed when it comes time to resolve it, since the information that it's a rename conflict isn't captured anywhere except, briefly, in the phosphors of your CRT.

In the author's example, when you run `git status`, it will simply tell you that `saludo` was added by them. Which is exactly the behavior of the rename-deficient git-merge-resolve. The expectation in resolving this, I suppose, is that you saw the message that this was a rename/delete conflict, remembered the original filename and could somehow make a decision based on that.

This is not terrible in a rename/delete conflict, but for some other types of rename conflicts, it's much more difficult. For example, branch 'A' renames a file from 'foo' to 'bar', branch 'B' renames it from 'foo' to 'baz'. Now you have two files in your working directory and git-status can only tell you that they were each added, which is not indicative of a conflict.

This is annoying for a user on the console. This is impossible for somebody trying to build a UI to resolve a merge conflict: 'bar' was added in one of the branches... why does this conflict? Well, if it's only on one side of the merge, then it must have come from some rename conflict. But with which other file? What's the common ancestor that git-merge-recursive decided was a rename? Meh.

(Please do not mistake this rant as a suggestion that Codeville's merge is superior to Git's. I'm not suggesting that, just that git-merge-recursive has a few rough edges that could use polish.)


I’ve been using git for nearly 15 years and not more than a half dozen times has resolving a merge conflict taken me more than 15 minutes.

This just isn’t a real problem. Try working more incrementally, or try working with colleagues who don’t rewrite large swaths of code without coordinating with their team.

You have a people problem, not a tool problem.


Haha, yeah, the reason it is a problem is because they’ve diverged so far.

If you can still merge the same changes to both branches you are home free.

Checking today and there’s differences in 2.5k files (out of 3.5k maybe?).

To be fair, a lot of that is cleanup, but still.


If you're getting a lot of conflicts then you have folks working on the same code and diverging it significantly. I honestly don't think that's a problem tooling will improve because it's really an organizational/communication problem. Engineers have to know when to rebase (or merge in changes from the target) if they're working on code with other engineers. If you merge in/rebase sooner, then things tend to be painless. If it's been weeks or months then let the Circus O' Pain begin. This should be fairly easy to recognize in stand up, eg: "Oh, you're working on that module? I need to track your changes, so am I."

The product being discussed here doesn't solve the issue of merge conflicts itself, but rather of eventual consistency. Merge conflicts is only a part of it, and there are some heuristics that can be used to reduce those, but eventually require manual review. Perhaps with Github Copilot this can improve?

An example of the problem we are describing is explained here: https://blog.mergequeue.com/managing-github-merges-for-high-...


> It's merging workflow is awful - I'm fine with correcting the odd whitespace-as-conflict, but I find the fact that git presents me with >>>>> eyebiting ====== conflict markers <<<<<< even when I'm using a merge tool difficult to excuse.

You might want to customize merge.conflictstyle

I do like the default of git however, and prefer it to, say, Mercurial.


Why are merge conflicts considered a problem? They're just git asking you what the source should really look like. They can be tricky to resolve but not insurmountable.

What this really looks like is a procrastination tool so that somebody can sit back and relax when they see someone else is changing the same area in the source.

I'd love to hear why I'm wrong.

next

Legal | privacy