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

前端 未结 27 1082
挽巷
挽巷 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:13

    If you only made changes and deleted a file, but not commit it, and now you broke up with your changes

    git checkout -- .
    

    but your deleted files did not return, you simply do the following command:

    git checkout 
    

    And presto, your file is back.

提交回复
热议问题