Unstage a deleted file in git

后端 未结 7 1760
我在风中等你
我在风中等你 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:03

    From manual page,

    git-reset - Reset current HEAD to the specified state
    git reset [-q] [] [--] ...
    In the first and second form, copy entries from  to the index.
    

    for example, when we use git reset HEAD~1 it reset our current HEAD to HEAD~1

    so when we use git reset 'some-deleted-file-path'

    git assume 'some-deleted-file-path' as some commit point and try to reset out current HEAD to there.

    And it ends up fail

    fatal: ambiguous argument 'some-deleted-file-path': unknown revision or path not in the working tree.
    

提交回复
热议问题