How to undo commits in git
This question already has an answer here:
git reset --hard HEAD
will reset it to your HEAD
.
To go 2 commits back use:
git reset --hard HEAD~2
If you just want to go back to what's in the remote repo, you can do:
git reset --hard origin/master
If you want to reset back to a particular local commit, just tell it the hash instead:
git reset --hard <hash of commit>
You might also first do a git fetch
to make sure you know about any changes in the remote repo.
上一篇: 忽略或跳过Git上的某些提交
下一篇: 如何在git中撤销提交