Git config";错误的配置文件行";在子模块中
我在Windows和Linux上使用git,最近我遇到了一个奇怪的问题,它只在Windows上出现。。。假设我有两个项目。这两个版本都是git版本,每个版本都有一个子模块Git config";错误的配置文件行";在子模块中,git,git-submodules,git-config,Git,Git Submodules,Git Config,我在Windows和Linux上使用git,最近我遇到了一个奇怪的问题,它只在Windows上出现。。。假设我有两个项目。这两个版本都是git版本,每个版本都有一个子模块 项目1 子模块配置位于C:\Projects\project1\.git\modules\plugins\tasks\config中,如下所示: [core] repositoryformatversion = 0 filemode = false bare = false logallref
项目1 子模块配置位于
C:\Projects\project1\.git\modules\plugins\tasks\config
中,如下所示:
[core]
repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
worktree = ..\..\..\..\plugins\tasks
symlinks = false
ignorecase = true
hideDotFiles = dotGitOnly
[remote "origin"]
url = ssh://domain/repo/path
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
项目2 子模块配置位于
C:\Projects\project2\.git\modules\doc\preamble\config
中,我还提供了以下内容:
[core]
repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
worktree = ../../../../doc/preamble
symlinks = false
ignorecase = true
hideDotFiles = dotGitOnly
[remote "origin"]
url = ssh://domain/another/repo/path
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
总之,配置文件之间唯一的真正区别是工作目录路径中的
/
和\
问题 我在Git Bash中操作。当我在项目1及其子模块中执行
git status
(以及一些其他简单命令)时:
/c/Projects/project1 (devel) $ git status
fatal: bad config file line 6 in c:/Projects/project1/.git/modules/plugins/tasks/config
fatal: 'git status --porcelain' failed in submodule plugins/tasks
/c/Projects/project1/plugins/tasks $ git status
fatal: bad config file line 6 in d:/Projects/project1/.git/modules/plugins/tasks/config
/c/Projects/project1 (devel) $ git submodule sync -- plugins/tasks/
Synchronizing submodule url for 'plugins/tasks'
fatal: bad config file line 6 in c:/Projects/project1/.git/modules/plugins/tasks/config
另外,git子模块init
或update
或update--init
不提供任何输出,也不会改善这种情况
然而,当我在project2中使用git
时,一切都正常
您可能认为最简单的解决方案是手动替换子模块配置中的斜杠,更复杂的解决方案是编写一个脚本,在所有受影响的子模块中都这样做
不幸的是,实际上,将第1个配置中的路径更改为:
worktree = ..\..\..\..\plugins\tasks
致:
导致不同的错误:
/c/Projects/project1/plugins/tasks $ git status
fatal: bad object HEAD
当我查看文件c/Projects/project1/.git/modules/plugins/tasks/refs/master
时,有些地方不对劲,因为里面的SHA1是:
0000000000000000000000000000000000000000
此时,在我执行了git reset--hard origin/master(在子模块中)之后,子模块的存储库恢复到可用状态
但是,首先哪里出了问题?
如果可能的话,我想知道为什么会发生这个问题?这是否与项目的原始平台有关?如何初始化子模块重要吗?我想找出这个问题的原因,以便将来避免它
git
像UNIX程序一样思考,所以前向斜杠是正确的。有关在Windowsgit
中使用前斜杠的一些示例,请参阅project1
重命名为project1.fubar
并重做git克隆foo://project1
您的目录应该
结果是正确的0000000000000000000000000000000000000000