Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+16 votes

I made a mistake while merging my code with someone else's in my group and we lost some work. I can see the old version before I basically erased what he did in the commit history on Github, but I don't know how to actually roll the repo back to that specific commit before I overwrote his work. How do I roll back the repo in Github to a specific commit in the past?

asked in CSC490_Spring202021 by (1 point)

3 Answers

+5 votes

You will want to use the git revert command. This will allow you to change to a past commit, then commit that code so that it only appears as a hiccup on your timeline. There is a good article here that explains how to use git revert just as I described. You will want to get the hash of the code commit, you should be able to see this in GitHub.com.

answered by (1 point)
+2

Got it! Thanks for the help!

+3 votes

The git revert command is a good way to go, have you already forked the repo?

answered by (-499 points)
+2

Got everything working again! Thanks!

+2 votes

I know you stated that you got it working but in case anyone else runs into it. You can do git log it will give you were your local changes and the master changes are as a snapshot. If you didn't push the git reset --hard HEAD^. If it was pushed then you can do git revert commit hash you can get the commit hash from the git log

answered by (1 point)
...