Retrieve missing files from remote repo?

前端 未结 3 960
被撕碎了的回忆
被撕碎了的回忆 2021-02-14 15:56

I accidentally deleted a few files from my local git repo.

I have not pushed this change to the remote.

Is there a easy way to get these files back from the remo

3条回答
  •  孤城傲影
    2021-02-14 16:46

    To discard all local changes, you can do:

    git checkout .
    

    To avoid losing local changes, do this instead:

    git ls-files -d -z | xargs -0 git checkout --
    

    (Taken from http://data.agaric.com/restore-locally-deleted-files-git They also suggest using git update -- . but that is not a valid git command.)

提交回复
热议问题