Hello, I had important site files inside a folder on my computer which was added as a project folder inside Atom. The files accidentally got added into Git and shown in the unstaged changes section. I chose to discard all changes, thinking that would just remove the list of files from Git, but it removed all the files inside that folder from my computer, without any way of recovering them. How can I get these lost files back now, as I’ve tried looking into the issue and no solutions solve my problem, and using file recovery software, nothing turns up. Thanks.
... menu of the git panel you can select “Undo Last Discard” (or search for it in the command palette).
I’m using 1.54.0, which I believe is the latest version. The
... option was there previously before I discarded all changes, but once I went ahead with the discard, that option was no longer available. The folder was never on a branch either, so not sure if that made any difference in this case.
That command seems to have no effect when used in the affected repository.
Hmm, then I don’t have any other way to try. I believe the undo support is based on Atom remembering the state, not git itself, so I don’t think there will be any git method of undoing it. It’s also weird that the menu has disappeared; I still see it even if there is nothing to restore and on a totally new repo (just ran
git init on a folder).
I guess that just leaves me with starting over completely on the project. Going back now, it does give me that option to undo discard changes, so I’m not exactly sure why that wouldn’t have been showing up previously. I’m just wondering what Atom does with those unstaged files after deletion, because I’ve looked through my entire system and ran a few recovery programs and haven’t found a single trace of where at least some cached versions would be located.
Although clearly you have tried recovery programs (which show deleted files even if deleted by design), if your lost data is important I would have a final stab at looking through your entire filesystem by installing and running ripgrep to hunt through your filesystem for files containing some pattern inside a file.
This will take quite some time and might not reveal anything after this effort. But I use ripgrep at times to hunt for misplaced files and it is useful to keep in your toolbox. Again this is searching for file content patterns rather than folder/file names. Ensure that you include hidden files in the search.
Installed ripgrep and tried to locate the files with some patterns that would likely turn up the missing files, but got no actual file results. However, ripgrep did reference some browser cache files, which I was able to go in and copy some of the cached file contents to get back most of my files. There wasn’t an available index.html file, which was the most important, since it seems to have been overwritten since the folder contents were deleted, but I was able to find that off a hard drive backup from 3 days previous. That file was partially corrupted, but I’m able to piece together most of the content to return the files back to a more recent state.
Still would like to know what actually went wrong in this case, but at least I’ve gotten some copies of the files that I can use as a starting point to build back up to the state the files were in when they were discarded.
Well done. Brushing up forensic skills is always useful.
There is a package
local-history which caches file backups as an insurance against such loss. They are saved in ~/.atom/local-history/. And running regular backups using say FileZilla in a cronjob.
Will definitely check that out. Looks like that would be the top solution to preventing any future file loss. Thanks.