1

Commits D & E were checked into branch XXX by mistake instead of YYY. We are trying not to use git reset to solve this.

So we have:

  • XXX: A -> B -> C -> D -> E
  • YYY: A -> B -> C

We reverted to commit C on branch XXX

git checkout XXX
git revert --no-commit C..HEAD
git commit 
git push

This gets you

  • XXX: A -> B -> C -> D -> E -> F (F is the revert)
  • YYY: A -> B -> C

Then we merged into branch YYY where we wanted to re-establish E as the head (without using reset).

git checkout YYY
git merge origin/XXX   

So now we have:

  • XXX: A -> B -> C -> D -> E -> F
  • YYY: A -> B -> C -> D -> E -> F

Then we tried to reset YYY to E

git revert --no-commit E..HEAD

BUT the revert commit gets you this error:

error: a cherry-pick or revert is already in progress hint: try "git cherry-pick (--continue | --quit | --abort)" fatal: revert failed

Tried using --continue but that didn't work.

How can we do this?

Marcus Leon
  • 55,199
  • 118
  • 297
  • 429

1 Answers1

0

Passing --no-commit to revert and then trying to use git checkout to switch branches isn't going to work.

# First cleanup branch XXX
git checkout XXX
git revert C..HEAD

Here, there is no need to try to revert multiple times. Just merge the original commits and then establish merge history for the revert

# now get the commits to YYY
git checkout YYY
git merge E 
git merge -s ours XXX
Andrew C
  • 13,845
  • 6
  • 50
  • 57