2

I'd like to revert every commit K if and only if:

  • K is one of two specific commits I want to reverse
  • or, K depends on one or more of these commits I want to reverse

For background, I'd like to have a local copy of Flutter that reverses these changes.

simplegamer
  • 212
  • 2
  • 10
  • A commit is not a “change”, and there is no sense in which one commit “depends” on another. So the whole question is meaningless. – matt May 07 '20 at 04:30

1 Answers1

1

You can tell if one commit (one of the two you want to revert) is an ancestor of another

git merge-base --is-ancestor <maybe-ancestor-commit> <descendant-commit>

So list every commits of every branch and:

  • if none of your 2 commits are ancestor of a branch HEAD, discard the branch
  • if they are, start enumerating commit from that branch

You might consider soft resetting that branch to before those commits: the index would be at the desired state: you can add and commit that index as one new commit which would reverse anything done since those commits (ancestors of a given branch)

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250