Generally, files added.gitignorewill 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
temporarilytraveled to that point in time, just find the file and copy it. Finally, just switch back, assuming you were just on the master branch:
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: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.
.gitignore
The specific method is:temporarilytraveled to that point in time, just find the file and copy it. Finally, just switch back, assuming you were just on the master branch:
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.