10

I'd like to convert my Git repository to a bare one. I distinctly remember something like git remove-tree that did the job previously but I can't find it on 1.7. Could you help me out?


Thanks guys, that did it with the moving of repo to a different place and then setting the bare=true option.

I must say my memory has failed me this time. The trick with removing working copy that I did previously was with Bazaar :)

Anyways - thanks for the answers.

Jeff Atwood
  • 62,295
  • 46
  • 147
  • 153
Matthias Hryniszak
  • 3,072
  • 3
  • 35
  • 50

2 Answers2

10

Cloning your git repository, as suggested in Skydreamer's answer, may be fine for what you want, but it would lose remote-tracking branches, settings in .git/config, etc. An alternative is to just reuse the .git directory as a bare repository, e.g. by doing:

cd my-repo
mv .git ../my-repo.git
cd ../my-repo.git
git config core.bare true

... which will leave my-repo with just your working tree, and my-repo.git as a bare version of the same repository.

Community
  • 1
  • 1
Mark Longair
  • 415,589
  • 70
  • 403
  • 320
2

git clone --bare old_directory new_directory

Cydonia7
  • 3,586
  • 2
  • 21
  • 32