John Kaff
John Kaff

Reputation: 2075

Is it possible to get files from .git folder

I cloned a git repo some time ago. After cloning the repo it had source files and a .git folder. Now there is only the .git folder. Somehow the files were deleted (a long time back).

These are the contents of the .git folder:

Mic-Pro:sample.git mic$ ls
HEAD        config      config_     description hooks       info        objects     refs

git status says the directory is not a git repo. Given only that .git folder, is there any way to recover those files?

I can't clone the repo as its not available anymore

Upvotes: 4

Views: 3055

Answers (2)

admix
admix

Reputation: 1782

Try this:

git init /tmp/recovery
cd /tmp/recovery
cp -r /path/to/broken/repo/.git/objects .git

More detailed: https://unix.stackexchange.com/questions/66891/how-to-recover-broken-partially-deleted-git-repository

Upvotes: 1

Philippe
Philippe

Reputation: 31137

If you have not messed the files in the '.git' folder, this command should fix your problem :

git reset --hard HEAD

Upvotes: 6

Related Questions