What are the steps to recover the source code from a .git directory containing objects and packfiles? How to configure the config file so it becomes just a local repository?
Asked
Active
Viewed 1,807 times
2 Answers
2
If this was a normal repository whose working directory got deleted, simply checkout what you want while in the parent of the .git directory, e.g. git checkout master
.
If it was a bare repository (i.e. it was your git server), then clone it into another directory with git clone <path to .git directory>
.

David Deutsch
- 17,443
- 4
- 47
- 54
-
Thank you. I don't have access to the git server anymore. Do I need to extract the packfiles before the checkout process? – Tigre Feb 04 '16 at 17:40
-
-
Sorry for the delay. It's a normal repository, but "git checkout master" only prints "Already on 'master' Your branch is up-to-date with 'origin/master'." – Tigre Feb 07 '16 at 07:58
-
2
A .git repository is named a bare repository. You can do what you want with this command :
git --git-dir=path_to_bare_repo.git archive HEAD | tar -x -C path_to_destination_dir
If you only want to convert a bare repository into a normal git repository, just follow the few steps of this link : How do I convert a bare git repository into a normal one (in-place)?
Operations are pretty simple :
mkdir repo_dir
mv path_to_bare_repo.git repo_dir/.git
cd repo_dir/.git
git config --local --bool core.bare false

Community
- 1
- 1

jbaptperez
- 656
- 6
- 20
-
Thank you very much! This did it: "git --git-dir=path_to_bare_repo.git archive HEAD | tar -x -C path_to_destination_dir" – Tigre Feb 07 '16 at 07:59