4

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?

Tigre
  • 73
  • 7

2 Answers2

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
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