TL;DR: I didn't add files, pushed updates and now I can't see the files in previous commits - I want to restore them.
What happened: When I committed one time, I forgot to add them to the index, and then reverted back to a previous commit.
Is there a way to restore those files, via a diff
or something? When git tries to commit while there are unadded files in the repository, what happens to those files? Does Git save information about them anywhere? Does it save them anywhere? Does it completely delete them?
I'm working on Visual Studio code and I've got GitLens, in case they can be of use.
Update: I think that I found that those untracked files were saved as either dangling blobs or unreachable objects. I'm currently checking this direction.
Found a solution:
*Note: this does not restore file names.
git fsck --unreachable
to get a list of all unreachable
objects which displays for each object their SHA-1 ID. git show <SHA-1 ID>
to read the contents of each object.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.