How do I convert a bare git repository into a normal one (in-place)?

Note: I tested this on a very simple 1-commit repository. Double-check this, read the man pages, and always be happy you’ve backed up before following advice you found on StackOverflow. (You do back up, right?)

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

  1. Make a .git folder in the top-level of your repository.
  2. Move the repository management things (HEAD branches config description hooks info objects refs etc.) into the .git you just created.
  3. Run git config --local --bool core.bare false to convert the local git-repository to non-bare.
  4. (via comment by Tamás Pap) After step #3 you will see that you are on branch master (or whichever your main branch is) and all your files are deleted and the deletion is staged. That’s normal. Just manually checkout master, or do a git reset --hard, and you are done.
  5. (to resolve issue reported by Royi)
    Edit .git/config file adding line fetch = +refs/heads/*:refs/remotes/origin/* after url = <...> in [remote "origin"] section. Otherwise git fetch will not see origin/master and other origin’s branches.

These steps are in the opposite direction of this question, “git-convert normal to bare repository” – in particular note this answer, which states that the above steps (in, I presume, either direction) is different from doing a git-clone. Not sure if that’s relevant to you, though, but you mentioned git clone in the question.

Leave a Comment