Okay, so I really like the git rerere
command, although I haven't really used it that much other than letting it auto-magically record my conflicts and resolve them for me. However, I did mess up one of my conflict resolutions during quite a large rebase (rebasing a really stale feature branch with the latest release).
feature -> a - b - c - d release -> e - f - g - h rebase/feature -> e - f - g - h . ` a' - b' - c' - d'
So, say for instance that b'
has an incorrect merge (thanks to me!), and I want to re-record that. How would I do it? I've seen the git checkout --conflict
option, mentioned in Rerere Your Boat, but I'm not too clear on how that works and if it applies here. Maybe I have to checkout the merge conflict state and run git rerere
once I correctly resolve this conflict?
Normally, I would just commit to the tip of the rebase branch, but it is a throw away. I'm just trying to handle conflicts ahead of time, so that when I sync up with that feature team, we minimize the time it takes. Make sense?
The git rerere functionality is a bit of a hidden feature. The name stands for “reuse recorded resolution” and, as the name implies, it allows you to ask Git to remember how you've resolved a hunk conflict so that the next time it sees the same conflict, Git can resolve it for you automatically.
@mittal: think of git rebase as copying commits from one branch onto another branch. So when you skip a commit, the original content of the commit is skipped and the patch is not applied (so all changes made to any file will not make it into your target branch).
To simply remove all previous rerere
resolutions, run rm -rf .git/rr-cache
to remove the cache.
For a specific merge, you can tell rerere
to forget the recorded resolution by re-executing the merge and allowing rerere
to apply its recorded resolution in the work tree.
You can check out a'
and then do a git merge b
to get back into that situation (you'll probably be in a checkout of a detached head since you specified the commit hash of a'
, so be aware that you're not on a branch).
Then use git rerere forget FILE-WITH-BAD-MERGE
where to specify the file whose recorded conflict resolution should be forgetten.
forget <pathspec>
Reset the conflict resolutions which rerere has recorded for the current conflict in .
(From the Git documentation for git-rerere.)
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