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

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

    For the best way to do that, try it.


    First, find the commit id of the commit that deleted your file. It will give you a summary of commits which deleted files.

    git log --diff-filter=D --summary

    git checkout 84sdhfddbffffdf~1

    Note: 84sdhfddbffffd is your commit id

    Through this you can easily recover all deleted files.

提交回复
热议问题