How to reset to my last commit in Android Studio

后端 未结 5 1920
北海茫月
北海茫月 2020-12-24 01:45

I commit changes to git from Android Studio, after that I have made some changes in my project that gives me errors, and now I want to get back that commited version that ha

5条回答
  •  庸人自扰
    2020-12-24 02:16

    Just get your commit id using git log. Then you can use (with 0d1d7fc32 for example):

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

    or if you don't want to save your changes (hard reset):

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

    If you want to go back to the last commit (without saving changes), then no need to get the id, go for:

    git reset --hard HEAD
    

    From this post

提交回复
热议问题