2

I have a couple of branches with many commits (~20-30) and some of them revert earlier commits from the same branch.

I now need to rebase those branches on current HEAD but I want to keep the revert commits, at least for now. (The branch is a port from another tree so it is valuable to see what is NOT used) Those commits usually have a message like "This reverts <SHA>" which will become invalid after the rebase.

Is there any option or tool to do the rebase but update the revert commit messages while doing so in a way so that they reference the new (rebased) commits?

Example history:

  • SHA0 Old HEAD
  • SHA1 Add Foo
  • SHA2 Add Bar
  • SHA3 Revert "Add Foo"\n\n This reverts SHA1

Should become:

  • SHA10 New HEAD
  • SHA11 Add Foo
  • SHA12 Add Bar
  • SHA13 Revert "Add Foo"\n\n This reverts SHA11
Flamefire
  • 5,313
  • 3
  • 35
  • 70
  • 1
    Not really, no - though `git filter-repo` does this particular trick, so if you can figure out how to do a rebase with filter-repo, that would get you there. – torek May 17 '21 at 19:57

0 Answers0