I am currently purging passwords and other sensitive data from a git repository. I would like to preserve the history as much as possible, including merges. So I am doing git rebase --interactive --preserve-merges <commit>
. Then I edit the instructions to edit the specific commits that I care about. During the rebase, I am surprised to see merge conflicts not related to my password editing. I believe these are conflicts that occurred with some of the existing merges in the history and were resolved at the time of the merge. Why isn't git able to just replay the commit that resolved these conflicts?
--preserve-merges
isn't compatible with --interactive
.
(All the quotes in this answer are from git help rebase
.)
This uses the --interactive machinery internally, but combining it with the
--interactive
option explicitly is generally not a good idea unless you know what you are doing (see BUGS below).
and
In addition, the following pairs of options are incompatible:
--preserve-merges
and--interactive
--rebase-merges
instead--rebase-merges
was introduced in Git 2.18 and --preserve-merges
was officially deprecated in Git 2.22.
The
--rebase-merges
mode is similar in spirit to the deprecated--preserve-merges
but works with interactive rebases, where commits can be reordered, inserted and dropped at will.
It still may not solve your problem:
Any resolved merge conflicts or manual amendments in these merge commits will have to be resolved/re-applied manually.
Even if it doesn't solve your problem, I think it definitively answers your question. Plus, you should be using this option anyway as --preserve-merges
is now deprecated.
There are more git help rebase
comments on --rebase-merges
. I recommend reading them.