Rollback to last git commit

后端 未结 6 2114
时光取名叫无心
时光取名叫无心 2020-12-22 16:05

I just did a

git commit -m \"blah\"

then I added some files, how do I rollback and remove what is in my current files that have not yet be

6条回答
  •  悲哀的现实
    2020-12-22 16:27

    Caveat Emptor - Destructive commands ahead.

    Mitigation - git reflog can save you if you need it.


    1) UNDO local file changes and KEEP your last commit

    git reset --hard
    

    2) UNDO local file changes and REMOVE your last commit

    git reset --hard HEAD^
    

    3) KEEP local file changes and REMOVE your last commit

    git reset --soft HEAD^
    

提交回复
热议问题