0

I accidentally ran git merge -s ours instead of git merge -X ours. This has already been pushed and several other commits (and regular merges) happened since then. What can I do now to restore the changes discarded by git merge -s ours? I tried checking out that commit and rebasing back to my branch but nothing works since git is telling me that its already up to date.

Cœur
  • 37,241
  • 25
  • 195
  • 267
kamilkp
  • 9,690
  • 6
  • 37
  • 56
  • Was this a fast-forward merge, or do you have a merge commit you can inspect? – Makoto Mar 14 '16 at 14:39
  • I have a merge commit – kamilkp Mar 14 '16 at 14:41
  • 1
    Possible duplicate of [How to revert a merge commit that's already pushed to remote branch?](http://stackoverflow.com/questions/7099833/how-to-revert-a-merge-commit-thats-already-pushed-to-remote-branch) – Makoto Mar 14 '16 at 14:41

2 Answers2

0

So for history like this:

o Merge (-sours)
|\
| \
o  o
P1 P2

I would assume you need to checkout some branch at P2 and run git rebase P1. Are you sure it does not rebase the content of your merged branch? I believe it should work.

max630
  • 8,762
  • 3
  • 30
  • 55
0

Reverting the merge commit worked.

kamilkp
  • 9,690
  • 6
  • 37
  • 56