I would like to make a repo into a bare repo so people can push to it with out big nasty warnings. I could delete it and clone it again... but perhaps there is a more elegant way?
It's probably best to just delete and clone again. Example:
mv old_git_repo/ /tmp/
git clone --bare /tmp/old_git_repo/ new_git_repo/
You could also just remove the working files and promote .git/*
to .
. However, you'd also need to add bare = true
and remove logallrefupdates = true
in the new bare config
's [core]
section (formerly .git/config
. You could make a script to do this automatically if you like.
Edit: You mentioned in a comment that this was cloned from svn, so a new clone will take a long time. But - don't clone from svn! Just clone from the new git repo, and it will be git -> git
, which will be fast. Or, see my note above about just moving the files.
A bare repository is simply a .git directory without the working directory. So you can simply replace the project dir with the contents of .git and it should work:
mv /path/to/projectdir /path/to/projectdir.old
mv /path/to/projectdir.old/.git /path/to/projectdir
rm -rf /path/to/projectdir