0

So this is pretty embarrassing, and it's also a big problem for me.

I am new to git and Github. I figured I would start by downloading the Github desktop app to learn how things worked. I created a repository from a location on my hard drive (the root folder of the project), but then decided to delete this repository. For whatever reason, Github moved my actual project folder (the root folder) into my trash bin, but when I went in there the only thing in the root folder was one folder that I included in my .gitignore file. Everything else seems to have vanished from my Mac, and I never even emptied the trash.

I have lost potentially 2 weeks of work, and have no idea what to do. I would not even know where to begin to fix this, and fear that my project is permanently lost.

Ginger and Lavender
  • 436
  • 1
  • 8
  • 21
  • You don't have the timemachine or cloud backup set up on your Mac? Are you able to discard changes on Github Desktop? To recover your deleted file, right-click on the file in GitHub and select discard changes. – DokuDoki Mar 19 '21 at 08:22
  • I remade the repository using the folder that was moved to the trash (the one from which all my files disappeared). In that repository is the first commit I made, which shows me all of the files that were deleted, and the files' content. Again, I am very new to Github, so I have no idea how to recover these files. I could manually copy and paste all of the content into new files, but there must be a better way. Interestingly, right clicking on the files in the desktop app reveals that "File Does Not Exist on Disk". – Ginger and Lavender Mar 19 '21 at 09:25
  • I had the same problem on **Windows 10**, however, no files were moved to the **recycle bin** and I've lost very important files! – Ahmed Suror May 15 '21 at 18:49
  • 1
    For future readers: on Win, if you just made this mistake, you may be able to get your work back by opening the parent directory in explorer and using ctrl+z to undo the delete operation. Hat tip to https://stackoverflow.com/a/57353750/449624 – underdark Nov 13 '21 at 18:45

1 Answers1

1

It happened to me also. I made a new repository on location that my actual project is, did commit and I was unhappy with .gitignore so I just removed repository. This shouldn't remove project from disk (it says in info box before deleting). Then I went to make a new repository on same location but with different .gitignore properties and my project cleaned like I never even coded

This helped me - if there's commit, there's a history tab which should have commits. If in history tab there's no commits, remove repository again and create new repository again on that same location with gitignore as before when files existed. When you click of first commit, there will be files shown on the right. When you hover over each of them Github should say there's no files on disk but will still preview them on the right. Then you can publish repository and clone it afterwards or copy/paste each file into notepad.

That did trick for me but if you didn't do any commits, I don't really know how to help you. Make sure to backup projects in explorer before doing initial Git stuff because this is a nightmare.

soggypants
  • 311
  • 2
  • 5