Git repository with git directory stored elsewhere

后端 未结 5 913
栀梦
栀梦 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:24

    Git interoperates with several other VCSes so this may not be the best way to solve your problem.

    However, it is possible: Using git-config you can tell git to use another directory, other than the one containing .git, as the root of the working tree.

    If you run git init one directory above the root directory foo of the other project, then you could use:

    git config core.worktree ../foo
    

    Where ../foo is the path of the foo project relative to your .git directory.

    However, with a relative path, the git tools will only work in the parent directory of foo, not anywhere else in the tree. By using an absolute path you avoid this (but have to remember to change it if you ever move your project).

提交回复
热议问题