Is there any way to recover the files added to .gitignore?
伊谢尔伦
伊谢尔伦 2017-05-02 09:50:46
0
3
988

Does anyone know how to recover files added to .gitignore? A file was deleted in ignore, but it was not displayed in the physical folder, and the cache was also cleared,,,

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

reply all(3)
迷茫

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
伊谢尔伦

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

黄舟

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template