I made some changes on my github site and its not working after I pushed it so I made so changes n try to push again.. still not workin.. so how can I rollback my github site two commits and to pushes ago>
Asked
Active
Viewed 443 times
3 Answers
0
git reset --hard HEAD~2
git push -f
The best advice would be to learn about the git reflog
and then you could just reset directly to the commit SHA desired.

cpjolicoeur
- 12,766
- 7
- 48
- 59
-
I dont know why I had to do the first line two times but it woked... – JMSAZ2013 Nov 25 '13 at 15:48
-
well I thought you said you needed to "undo" 2 commits. If it was really 4 then you whould have needed to do it twice or you could have just done `git reset --hard HEAD~4` really tho, learn about the `git reflog` and you could have just reset directly to the sha – cpjolicoeur Nov 25 '13 at 15:50
-
1@JMSAZ2013 , you can read more about reset here http://git-scm.com/blog/2011/07/11/reset.html . Also, you can read progit book - it explains lot more about git. http://git-scm.com/book – Isantipov Nov 25 '13 at 19:46
0
Use git revert sha1
command. Get the sha1
by running git log
. Push after you are done.

Ruslan Osipov
- 5,655
- 4
- 29
- 44
0
You would rollback your local machine, then force a push to github... I'd recommend creating a copy of what you have since the rollback will be destructive. This also assumes the branch you want to rollback is master
:
git checkout -b backup_branch # create backup branch
git checkout master # checkout branch to rollback
git reset --hard HEAD~2 # reset to 2 revisions before the HEAD
git push --force origin master # force push to github

CDub
- 13,146
- 4
- 51
- 68