Search code examples
androidgitgithubrecoverygithub-desktop

Is it possible to restore my project from compression after deleting repo?


In a stroke of genius, I deleted my repo from github because I was having problem committing a certain change (it's very early stage so I thought why not). This is an android project. I then wanted to create the repo again using github desktop so I did so on the Android project that I've been working on for days. When I did this and went back to Android Studio, it seems like it reverted back days of progress I made. How can this happen locally? Did I somehow lose my local project changes when I deleted the repo on github?

I don't know if this will help but before I did anything stupid like deleting my repo and trying to create it again, I compressed my whole project including the .git into a zip file. Is it somehow possible to recover from this compressed file? When I looked into the contents of the zip file (I uncompressed a version), it seems like the progress reverted there too...

Do I need to just accept my fate that I lost my progress?

This is the steps I took to mess up:
1. I made a zip of my local project thinking this was a surefire backup in case something went wrong when deleting repo
2. I deleted the repo from github.com thinking I would just recreate the repo in Github Desktop
3. In Github Desktop, I "removed" the repo since it is now deleted
4. In Gitub Desktop, I created the new repo and attached it to my local project
5. I went back to my local project (Android Studio) and noticed a bunch of my progress was lost. Lots of my files were red like something was wrong.

This is what I have tried to do to fix it, I am being really hesitant in case I screw up even more:
1. I uncompressed my zip file to see if my progress was in there like any new .java files but they weren't. I searched my project and I did notice the .class files though.. not sure what that means.. It doesn't appear to be. I don't understand that since I thought if I compressed the .git in the local project all would be ok? It wasn't.


Solution

  • If you have recreated a new empty repo on GitHub, then you can associate it to your uncompressed zip archive.

    If said zip archived included the .git subfolder, then all you need to do in its restored folder (once uncompressed anywhere you want) is:

    cd /path/to/new/local/repo
    git remote set-remote origin https://github.com/<me>/<myNewEmptyRepo.git>