July 19, 2017

Convert a Bare git repository into a normal

Assume that we have a bare repository.

To convert a --bare repository to a non-bare:

1. Make a .git folder in the top-level of your repository.
mkdir .git

2. Move the repository management things (HEAD branches config description hooks info objects refs etc.) into the .git you just created.

mv branches/ .git/
mv config  .git/
mv FETCH_HEAD .git/
mv HEAD .git/
mv hooks/ .git/
mv logs/ .git/
mv objects/ .git/
mv packed-refs .git/
mv refs/ .git/

3. Run git config --local --bool core.bare false to convert the local git-repository to non-bare.

4. Run git reset --hard or just manually checkout master.


Batch Script Example:
mkdir .git
mv branches/ .git/
mv config  .git/
mv FETCH_HEAD .git/
mv HEAD .git/
mv hooks/ .git/
mv logs/ .git/
mv objects/ .git/
mv packed-refs .git/
mv refs/ .git/
git config --local --bool core.bare false
git reset --hard