首页 > 解决方案 > 是否支持在 .git 文件中指定工作树?

问题描述

我在一个.git 文件中有这个:

gitdir: path\to\git-dir

我还想添加工作树目录,阿拉

worktree: path\to\work-tree

git 支持吗?

标签: git

解决方案


我找到了解决我的问题的方法 [供将来参考:https ://rakhesh.com/coding/how-to-move-separate-the-git-folder-out-of-your-working-tree ]。

可以在 git 文件夹配置文件中指定工作树 [不是在 .git 文件中,而是];通过添加worktree一行。就这么简单:)

示例git-dir/config文件:

[core]
    repositoryformatversion = 0
    filemode = false
    bare = false
    logallrefupdates = true
    symlinks = false
    ignorecase = true
>>  worktree = <path/to/work-tree>

推荐阅读