How can I unstage my files again after making a local commit?

前端 未结 7 841
灰色年华
灰色年华 2020-12-22 16:16

I have executed the following command

git add 
git commit -m \"add the foo.java file\"

How can I delete my local commit now

7条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-22 16:19

    Lets say you want to unstage changes upto n commits,

    Where commit hashes are as follows:

    • h1
    • h2 ...
    • hn
    • hn+1

    Then run the following command:
    git reset hn

    Now the HEAD will be at hn+1. Changes from h1 to hn will be unstaged.

提交回复
热议问题