如何让git includeIf工作在子模块

sirbozc5  于 2023-08-01  发布在  Git
关注(0)|答案(2)|浏览(140)
[core]
    editor = \"C:\\Microsoft VS Code\\bin\\code\" --wait

[includeIf "gitdir/i:D:/code/project/"]
   path = project.gitconfig

[includeIf "gitdir/i:D:/code/project/acts/ccxt/ccxt"] # not working, why?
    path = github.submodule.gitconfig

[includeIf "gitdir/i:E:/code/project/"]
    path = project.gitconfig

[includeIf "gitdir/i:d:/OneDrive/code/"]
    path = project.gitconfig

[includeIf "gitdir/i:D:/code/github/"]
    path = github.gitconfig

字符串
D:/code/project/acts/ccxt/ccxtD:/code/project/acts/的一个子模。除子模块中的includeIf外,所有includeIf都正常工作。如果我注解掉D:/code/project/acts/并将D:/code/project/acts/ccxt/ccxt更改为D:/code/project/acts/,它就可以工作,但我需要为ccxtproject设置不同的设置。

disbfnqx

disbfnqx1#

通常情况下,git仓库的配置位于.../repository/.git/config中。在子模块中,该配置实际上并不位于子模块的.git目录中,而是位于父存储库的.git目录中。
在本例中,父存储库是D:/code/project/acts/,因此子模块的config目录实际上位于D:/code/project/acts/.git/modules/ccxt/ccxt/config中。这意味着你的includeIf应该看起来像这样:

[includeIf "gitdir/i:D:/code/project/acts/.git/modules/ccxt/ccxt"]
    path = github.submodule.gitconfig

字符串

7d7tgy0s

7d7tgy0s2#

我终于通过删除尾部的斜杠(只针对子模块)使它工作了
gitconfig:

[user]
        email = "peter@default.com"
        name = "Peter"
        signingKey = "23DAXXXXXXXX"

[includeIf "gitdir:~/repos/company/"]
        path = "/nix/store/464dis986sd2rgqxhf18wyixm68n0iv2-company-gitconfig"

[includeIf "gitdir:~/.password-store/.git/modules/company"]
        path = "/nix/store/464dis986sd2rgqxhf18wyixm68n0iv2-company-gitconfig"

字符串

相关问题