how-do-i-revert-a-git-repository-to-a-previous-commit

https://stackoverflow.com/questions/4114095/how-do-i-revert-a-git-repository-to-a-previous-commit

Normally

# This will detach your HEAD, that is, leave you with no branch checked out:
git checkout 0d1d7fc32

Hard delete unpublished commits

If, on the other hand, you want to really get rid of everything you've done since then, there are two possibilities. One, if you haven't published any of these commits, simply reset:

# This will destroy any local modifications.
# Don't do it if you have uncommitted work you want to keep.
git reset --hard 0d1d7fc32

posted on 2021-01-07 18:00  cdekelon  阅读(45)  评论(0编辑  收藏  举报

导航