When cherry-picking a commit with similar resolutions to a previously resolved patch I sometime see git saying it tried to re-apply what I'd done earlier. I believe this is the rerere
component of git.
$ git cherry-pick ...
error: could not apply a123f6c424... [commit message]
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'
hint: and commit the result with 'git commit'
Resolved 'path/to/file.c' using previous resolution.
The problem is I don't trust my previous resolution. How can I see what the "previous resolution" did? I.e. the diff of just the conflicting areas.
I know I can re-do the merge completely with the following commands. However, I don't want to completely throw away the previous work, just review and validate it.
git rerere forget path/to/file.c
git checkout -m path/to/file.c
# Resolve. e.g., git mergetool
The following questions are similar but are for merge commits, not conflicts in general or uncommitted changes.
I ran into this same issue recently, though I was rebasing instead of cherry-picking, but I don't think there should be a difference. Here's a flow that should work:
First, abort the operation where the conflict occurred:
git cherry-pick --abort
Then, repeat the operation with rerere functionality disabled:
git -c rerere.enabled=false cherry-pick ...
Observe the conflicts.
Apply the recorded resolution manually:
git rerere
It's a bit tedious, but I think it achieves what you're wanting. I'd love if there were a way to show a diff of the merge attempt (with conflicts) against the resolution like git show --diff-merges=remerge
, but I'm not sure if there's a straightforward way to get that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With