search

Home  >  Q&A  >  body text

git 找回被误删的文件

今天发现github 中某个文件丢失了,只记得些文件名的一些关键词,搜索了下,使用

 git ls-files --deleted

没有效果。

请问下 是否可以通过一些关键词找到被删除的文件,然后恢复。

我的git version 是 1.9.4-preview20140929.

感谢。

滿天的星座滿天的星座2771 days ago667

reply all(4)I'll reply

  • 漂亮男人

    漂亮男人2017-04-28 09:07:55

    git checkout to try an earlier version?

    reply
    0
  • PHPz

    PHPz2017-04-28 09:07:55

    This software is called Git, not GitHub!

    git log -S字符串 或者 git log -G正则 可以搜索。具体功能和用法请见手册(man git-log).

    reply
    0
  • 仅有的幸福

    仅有的幸福2017-04-28 09:07:55

    Gitk gives it a try, brings up the visualization window, and uses the search function to search for the file.

    reply
    0
  • 为情所困

    为情所困2017-04-28 09:07:55

    Just checkout the file directly from the local server. There is no need to pull it from the remote server
    Because all historical versions are available locally.

    git checkout file

    Recover multiple deleted files at the same time:
    git ls-files -d | xargs -i git checkout {}

    Reference: How to restore locally deleted files with git

    reply
    0
  • Cancelreply