0

I accidentally merged in a huge branch into my branch and pushed to the remote repo.

I need to 'reset' back to a previous commit on my branch, before I did this accidental merge.

I've looked at many similar questions on Stack Overflow and they all say to just use

git reset --hard <sha1_of_where_you_want_to_be>

which I have done. But I don't see any changes. git status shows nothing and when I push back up to my remote repo nothing changes.

Would anyone know what I am doing wrong or what I should do next?

MeltingDog
  • 14,310
  • 43
  • 165
  • 295
  • Please _don't_ use hard reset here. Instead, use `git revert`, following the accepted answer in the duplicate link. – Tim Biegeleisen Aug 15 '19 at 06:09
  • @TimBiegeleisen that's fine, but then I cannot push it back up to the remote branch as it sees my local branch as behind it. It prompts me to `git pull` which would just pull down the unwanted files again. – MeltingDog Aug 15 '19 at 06:14
  • 2
    That shouldn't be happening, because `git revert` adds a _new_ commit on _top_ of what is already there. If it sees your local branch as behind, then maybe you need to `git pull` first, then do the revert. – Tim Biegeleisen Aug 15 '19 at 06:15
  • Thanks @TimBiegeleisen, that did the trick – MeltingDog Aug 15 '19 at 06:17
  • 1
    For the record, the reason I didn't answer is because I just would have been paraphrasing the duplicate link. I discourage this, including on myself, so I just left comments instead. – Tim Biegeleisen Aug 15 '19 at 06:18
  • Yes I understand. The SO questions I encountered did not have the answer your linked to. – MeltingDog Aug 15 '19 at 06:54

0 Answers0