I have a server on which I have a bare repository for pushing. However, my server needs to have a working copy of the master branch.
How do I get a working copy and
This is how it works:
$ git init --separate-git-dir /path/to/existing-bare-repository /path/to/workdir
$ cd /path/to/workdir
$ git checkout .
Voilà!
For info: git init
will report: Reinitialized existing Git repository in /path/to/existing-bare-repository
. But be confident. man git-init
says:
Running git init in an existing repository is safe. It will not overwrite things that are already there.
The magic is that git init
alone does not make your files appear in the working directory. You have to checkout the root directory.