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

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

    I came to this question looking to restore a file I just deleted but I hadn't yet committed the change. Just in case you find yourself in this situation, all you need to do is the following:

    git checkout HEAD -- path/to/file.ext

提交回复
热议问题