Git repository with git directory stored elsewhere

后端 未结 5 916
栀梦
栀梦 2020-12-31 17:48

I\'m sorry if this is a duplicate, I\'ve searched google and SO and couldn\'t find anything similar since it\'s a fairly generic set of words to search for!

What I w

5条回答
  •  佛祖请我去吃肉
    2020-12-31 18:39

    You can specify the path to the git repository explicitly with the --git-dir global option for all git commands. When you use this option with init it usually creates a bare repository but if you supply --work-tree as well you can initialize a non-bare repository with a 'detached' working tree.

    git --git-dir=/var/repo/one.git --work-tree=/var/work/one init
    

    From then on, you still have to supply either the --git-dir option or set GIT_DIR environment variable so that git knows where the repository is as there is no git specific data at all inside the working tree, but the working tree will be determined appropriately from the git repository config.

提交回复
热议问题