search

Home  >  Q&A  >  body text

加入.gitignore的文件有什么办法恢复出来不?

有木有人知道加入.gitignore的文件有什么办法恢复出来不?ignore里删掉了一个文件,但是在实体文件夹里并没有显示出来,而且也清理过缓存了,,,

伊谢尔伦伊谢尔伦2766 days ago952

reply all(3)I'll reply

  • 迷茫

    迷茫2017-05-02 09:52:46

    Generally, files added .gitignore will not be deleted locally. If you have not deleted them locally, you can definitely get them back. But I don’t quite understand some of the poster’s descriptions. What is meant by:

    A file was deleted in ignore, but it is not displayed in the physical folder

    Did you delete that file manually? If this is the case, git cannot indeed retrieve it, because it was not deleted through git operations, and git is not responsible for this. If you want to get it back, don't rely on git, but look for other file recovery software. Some software can help find accidentally deleted files.

    In addition, if that file has been included in git management before, it is also possible to find it. For example, if you have submitted certain files before and then added them later, this will work. You can also get them back by switching to a previous commit. .gitignoreThe specific method is:

    • To find the hash value of the submission where the file still exists (a bit hard to pronounce, but you can understand it), you can do this:

    • git log
    • Let’s say that commit’s hash is 31d3ea7a8 and switch to that commit (it’s a safe thing to do, don’t worry):

    • git checkout 31d3ea7a8
    • Now that you have

      temporarily traveled to that point in time, just find the file and copy it. Finally, just switch back, assuming you were just on the master branch:

    • git checkout master

      reply
      0
  • 伊谢尔伦

    伊谢尔伦2017-05-02 09:52:46

    First remove that file from the ignore file, and then git checkout there is a commit of the file before. Then perform recovery and other operations

    reply
    0
  • 黄舟

    黄舟2017-05-02 09:52:46

    You can go to your Git repository and have a look.

    reply
    0
  • Cancelreply