-1

Ok, so I merged a file really badly late last night and then pushed to origin (but it's not in upstream.)

I want to either wind back to before the bad merge, or checkout the file from before the merge and somehow re-merge it against the upstream copy.

What's safe to do here and how do I do it?

Eloff
  • 20,828
  • 17
  • 83
  • 112
  • Duplicate of [How to undo the last Git commit?](http://stackoverflow.com/questions/927358/how-to-undo-the-last-git-commit) and [Undo a Git merge?](http://stackoverflow.com/questions/2389361/undo-a-git-merge). –  Aug 06 '13 at 18:39
  • So the answer is rebase, it doesn't matter if you've pushed the repo, what counts is if anyone else has pulled from you (if you don't know for sure then assume they have and don't rebase.) – Eloff Aug 06 '13 at 21:25

2 Answers2

0

If you've already pushed it to a location where others pull from, your safest option is to use git revert. This will create another commit that reverses the changes from the bad commit.

That way, you won't rewrite history, which could be bad if others pulled your bad commit already.

gtrig
  • 12,550
  • 5
  • 28
  • 36
0

The easiest thing it simply to checkout your previous version of the file and then committing it again with the right version that you need.

CodeWizard
  • 128,036
  • 21
  • 144
  • 167