Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialgerardo barroso
42,674 PointsHow to get a local repository back using git
hey I'm curious to know, if i can get a copy of my local folder(project) using git, even if i deleted my folder accidentally from my desktop and haven't pushed my commits to github so I would not be able to clone the repo, but I committed locally.
1 Answer
miguelcastro2
Courses Plus Student 6,573 PointsYou can't.
If you have a local Git repo and you delete the project folder containing the Git repo and you never pushed the contents of the repo to a remote location such as GitHub, then you cannot recover it. You have to imagine it this way, if you have a directory called "Projects" and that directory is under Git version control, all Git related information regarding that directory is stored inside "Projects" in a .git directory. If you do not synchronize your local "Projects" folder with a remote repository then once you delete the "Projects" folder all information is lost. There is no other place the local Git repository stores information.