3

I need some help please! I'm using Adobe Brackets and I was just trying out its Git extension, when I accidentally clicked on "Discard all changes since last commit". Since I had not done any commit, ALL my files are now gone. Everything, the entire website I was working on! Including images, HTML, CSS, JS... I don't know what to do. The files are not in even in the trash.

Can someone please tell me if there is any way to recover the files I lost? Any help is much appreciated!

  • what says 'git status'? – clash Jan 20 '15 at 14:45
  • Oops. Maybe a file recovery tool could save some of them. But the chances are low. – axiac Jan 20 '15 at 14:47
  • git status says `On branch master Your branch is up-to-date with 'js/master'. nothing to commit, working directory clean` – Jonas Schmedtmann Jan 20 '15 at 14:50
  • @axiac I'm trying that now, but it doesn't seem to work. Do you know any good mac app for that? – Jonas Schmedtmann Jan 20 '15 at 14:51
  • Do you have a TimeMachine running? OSX creates hourly backups for the last 24 hours. You can find your files in the last of them (or in the previous one if it happened to take another snapshot since you deleted the files). – axiac Jan 20 '15 at 14:56
  • @axiac No, unfortunately I don't have a TimeMachine set up :( but I guess I will do that for the future... – Jonas Schmedtmann Jan 20 '15 at 15:01
  • Have you added the changes to the index at some point (`git add`)? You may have luck finding the file contents using `git fsck`. Take a look at [this question](http://stackoverflow.com/questions/1108853/recovering-added-file-after-doing-git-reset-hard-head). – Sascha Wolf Jan 20 '15 at 15:17
  • 1
    Also relevant: http://stackoverflow.com/questions/7374069/undo-git-reset-hard-with-uncommitted-files-in-the-staging-area – Sascha Wolf Jan 20 '15 at 15:20
  • No I didn't, I was just playing around with Git in the Brackets app for this first time when this happened. – Jonas Schmedtmann Jan 20 '15 at 15:22

1 Answers1

0

No way... when you have no commit and you reset or checkout your files all your changes are lost.

Not committed changes are in the working tree.

http://www.ralfebert.de/git/aenderungen-verwerfen/

René Höhle
  • 26,716
  • 22
  • 73
  • 82
  • Thanks for your answer... But where the hell do the files go? Why are they not even in the trash? – Jonas Schmedtmann Jan 20 '15 at 14:55
  • The files were changed back to the last commit thats the concept of GIT. – René Höhle Jan 20 '15 at 14:57
  • 3
    The Trash is not implemented at the file system level. It is a feature provided by higher level of the operating system. A deleted file goes in Trash if the application that deletes it puts it there. The OS provides a function for this purpose. `git` probably uses the function `unlink()` (which is the standard Unix call to remove a file) in order to be portable across different OSes. Anyway, because the deletion was not explicitly requested by you but it was an effect of the `git reset` command, it's unlikely that any program will move the deleted files into the Trash in such situation. – axiac Jan 20 '15 at 15:02
  • Ok, I see. So I guess that means there is really no way of getting these files back. This really sucks... – Jonas Schmedtmann Jan 20 '15 at 15:17