Unstage a deleted file in git

后端 未结 7 1765
我在风中等你
我在风中等你 2020-12-04 04:28

Usually, to discard changes to a file you would do:

git checkout -- 

What if the change I want to discard is deleting the file?

7条回答
  •  再見小時候
    2020-12-04 05:24

    Assuming you're wanting to undo the effects of git rm or rm followed by git add -A or something similar:

    # this restores the file status in the index
    git reset -- 
    # then check out a copy from the index
    git checkout -- 
    

    To undo git add , the first line above suffices, assuming you haven't committed yet.

提交回复
热议问题