I already created a repository. Can I make it a bare type or shall I start over?
views:
281answers:
3
+2
Q:
When creating a git repository that will be on the server, can I convert it to a bare repository?
+6
A:
Just move the .git
folder away from the working copy.
mv /var/git/repo/repo/.git /var/git/repos/repo.git
You might want to follow that up with a
git config core.bare true
in that repository, just in case git
complains about something not being right.
Bombe
2009-11-23 17:07:45
how do I create a bare repo rigth from the start?
mrblah
2009-11-23 17:15:35
mipadi
2009-11-23 17:19:06
Or just `git init --bare myrepo.git`
Jörg W Mittag
2009-11-23 19:53:14
Note that being able to do `git init --bare` as an alternative to `git --bare init` came in in v1.5.6 ~Jun 08.
Charles Bailey
2009-11-23 20:49:01
+8
A:
According to the FAQ, conversion from non-bare to bare can be done in two ways. The best one:
$ git clone --bare repo repo.git
$ rm -rf repo
To create a bare repository from scratch:
$ mkdir repo.git
$ cd repo.git
$ git --bare init
Jørn Schou-Rode
2009-11-23 17:16:34
Why is the first method "easier"? The second method seems both safer *and* easier (you don't need the renames to get the same result as the first method, just `git clone --bare repo` followed by `rm -rf repo` will do).
Dan Moulding
2009-11-24 14:30:31
@Dan is right, and I have modified my answer to only contain the safe *and* easy approach. With the version of git on my box (1.5.6.5), I still need to provide the target directory when calling git-clone, though.
Jørn Schou-Rode
2009-11-24 15:04:45
Doesn't `git clone` set the `origin` remote to the one cloned from? In this case to `./repo`, which you `rm`'d...
Boldewyn
2010-02-04 19:12:39
+2
A:
git clone --bare repo
This will give you a new bare version of repo
named repo.git
. Easy, no?
Dan Moulding
2009-11-23 19:07:53