How to find and restore a deleted file in a Git repository

前端 未结 27 1474
挽巷
挽巷 2020-11-22 01:25

Say I\'m in a Git repository. I delete a file and commit that change. I continue working and make some more commits. Then, I find I need to restore that file.

I know

27条回答
  •  时光取名叫无心
    2020-11-22 02:22

    Simple and precise-

    First of all, get a latest stable commit in which you have that file by -

    git log 
    

    Say you find $commitid 1234567..., then

    git checkout <$commitid> $fileName
    

    This will restore the file version which was in that commit.

提交回复
热议问题