4

git-rerere is the exact solution to a problem I have ... except that the merges that need to be "learnt" have already been performed and are non-trivial to repeat.

How can I "teach" rerere about those commits with the minimum manual intervention.

Supposing that existing, but conflicting, branches A and B were merged together to form commit C with resolved conflicts. Then I was hoping to do:

  • git checkout A
  • git merge B
    • merge pauses when conflicts observed.
  • git reset --soft C
    • working files are now in the desired final state - i.e. the conflicts were "resolved".
  • git merge --continue
    • rerere sees the updated files as the appropriate resolution, and "learns" this resolution.

But the reset step doesn't work :(

  • A --soft reset isn't permitted during a merge.
  • A --mixed reset nukes MERGE_HEAD (and I assume generally screws around with the git state, such that the merge cannot be resumed)

EDIT:

Manually "resetting" the files, by checking out C before hand and copying over the relevant files works but is quite slow and tedious due to the large and complex nature of the repositor.

(lots of projects in separate folders, each with their own node_modules/packages folders that will tank the copy time, unless I target specific folders :( )

I'm hoping for something automated. #optimism

Brondahl
  • 7,402
  • 5
  • 45
  • 74
  • What about just checking out C somewhere else and copying files over? – jurez Jul 08 '22 at 12:59
  • Yes, that's the manual intervention option I have, and am hoping to avoid, because there are dozens of these merges that I have to "teach". – Brondahl Jul 08 '22 at 13:04
  • I'm not sure I understand the problem then. You can automate it in the same way as above steps - simply put the commands in a shell script and iterate over all the cases with some kind of loop... – jurez Jul 08 '22 at 13:34
  • Yes, that would certainly work. Or I could just run `dedicated-git-command-that-i-don't-know-about-to-tell-rerere-to-learn-the-contents-of-that-merge-commit` ... if it exists and SO can tell me about it. – Brondahl Jul 08 '22 at 13:42
  • That's why I didn't ask "how can I script this specific sequence of steps". You should know by now that SO *loves* to tell people that they have XY-Problems :) – Brondahl Jul 08 '22 at 14:07
  • 2
    Git includes a script, [`contrib/rerere-train.sh`](https://github.com/git/git/blob/master/contrib/rerere-train.sh), that will help you out. You'll probably have to fuss with it a bit. – torek Jul 08 '22 at 21:19

0 Answers0