Welcome to the CSC Q&A.
Get help and give help!
Write great code!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+11 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.2k points)

3 Answers

+3 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 (2.4k points)
0

Got it! Thanks for the help!

+1 vote

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

answered by (1.2k points)
0

Got everything working again! Thanks!

0 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.3k points)
...