Getting a working copy of a bare repository

前端 未结 7 702
渐次进展
渐次进展 2020-12-08 09:35

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

7条回答
  •  [愿得一人]
    2020-12-08 10:25

    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.

提交回复
热议问题