-3

My local repo is the latest one, then the GitHub repo is a little older, and then there's another repo that is the oldest, and I made some temporary changes to the oldest repo, then accidentally pushed to GitHub (what i wanted was to push the local one to GitHub).

Now, what I want to do is to reset hard on the GitHub repo to undo the accidental commit as if nothing ever happened, how should I do it? Should I pull the GitHub repo inside a new folder and then revert it and then push it back to GitHub?

Andy
  • 115
  • 6

1 Answers1

1

Find the SHA1 of the commit you want to be the latest one on the github repo. This will probably be the commit right before the ones you didn't want to push.

Then on your old repo do: git reset --hard git push --force origin master

(or whatever remote and branch names you have)

This should do the job. Also make sure that everyone who has pulled/cloned the "bad" commit too removes it using these commands, otherwise it'll get pushed again when they push.

Dirbaio
  • 2,921
  • 16
  • 15