Tho*_*ard 6 git git-submodules
最近Git的更改改变了.git
使用子模块时目录的处理方式..git
现在,所有内容都位于"根级别" .git
目录(与包含子模块的工作副本相对应的目录)中,而不是每个子模块有一个.
然后,在每个子模块中,创建一个指向.git
目录新位置的文件.
在我的项目中,我有以下.gitmodules
文件:
[submodule "tests/shared-tests"]
path = tests/shared-tests
url = git://github.com/roboptim/roboptim-shared-tests.git
[submodule "cmake"]
path = cmake
url = git://github.com/jrl-umi3218/jrl-cmakemodules.git
Run Code Online (Sandbox Code Playgroud)
当我这样做时git clone --recursive
,我获得:
$ cat cmake/.git
gitdir: /home/moulard/profiles/default-x86_64-linux-ubuntu-12.04.1/src/unstable/roboptim/roboptim-core/.git/modules/cmake
Run Code Online (Sandbox Code Playgroud)
我目前正在使用Git 1.8.1.5.
我的问题是:
请注意,这是不一样的前一个问题移动包含子模块一个Git仓库的父目录在这个意义上,我肯定这不是一个绝对路径在我的存在相关的问题.gitmodules
的文件.
该.git/module
组织的历史可以追溯到git1.7.8(2011年12月2日):
使用"
git submodule init
" 填充新的子模块目录时,子模块的$GIT_DIR
元信息目录$GIT_DIR/modules/<name>/
在超级项目的目录内创建,并通过gitfile机制引用.
这样就可以在没有重新克隆的情况下在超级项目中提交和在树中没有子模块的提交之间进行切换.
但是,最近的错误修复已包含在1.8.2.1和1.8.3(2013年4月22日)中:
"git submodule update",当递归到子子模块时,没有累积前缀路径.
所以升级到最新的git版本可以解决这个问题.
在这里,OP Thomas Moulard在评论中提到了一种可能的解决方案(最新的git 1.8.3,2013年4月22日):
$ git submodule deinit -f .
工作中!
然后我可以运行git submodule init
并修复路径
如果(de)初始化步骤(.git/modules
),这需要注意
它不会处理add
在.gitmodules
文件中记录子模块的URL的步骤:您仍然需要在该文件中手动删除它.