On Mon, May 15, 2023 at 03:22:09PM -0700, Dan Stromberg wrote: > But in summary, how can I get the merge conflict to go away? I'm surprised > that the > add+commit+rebase --continue isn't enough to deal with that file. > > > It turned out I needed to: > 2715 git add requirements.txt.m4 > 2716 git commit -m 'Merge conflicts' requirements.txt.m4 > 2717 git rebase --continue > 2718 cp ../../requirements.txt.m4 requirements.txt.m4 > ...multiple times, after the initial git rebase. > > Speculation: Could this be because there were multiple changes to that file?
Ah, that might indeed easily explain the observed behavior: `git rebase` textually applies each commit from those your branch has compared to the "base" branch, one-by-one, and each application may fail due to conflicts. I honestly have no idea what exactly you are trying to achieve (I cannot fathom any non-far-fetched reason to commit a file which is in a conflicting state) but I think the easiest fix would be to somewhat reverse your workflow: instead of rebasing you could go with a "squash merge". Basically, instead of doing `git rebase master`, you could do git reset --hard master # this would save the current HEAD as HEAD@{1} git merge --squash HEAD@{1} git commit -a -m 'Merge conflicts' A "squash merge" produces a single commit out of any set of changes which are about to be merged, so you're going to get a single conflict no matter what (well, except if here's simply no difference to be merged in the first place). Note that the approach just demonstrated relies on the so-called "reflog" to be turned on, which is always the case for "normal" repositories unless explicitly turned off. I would also suggest to look at `git rerere` - may be this is a more suitable tool for your use case. > We were also wondering if the 'git commit' was strictly necessary. If we're talking about a merge conflict in a middle of a rebase operation, then no, it suffices to mark all outstanding conflicts as resolved (`git add` is one way of doing so) and then continue rebasing. -- You received this message because you are subscribed to the Google Groups "Git for human beings" group. To unsubscribe from this group and stop receiving emails from it, send an email to git-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/git-users/20230516124626.vzfoyr2ptvn44ic5%40carbon.