我已经运行以下git命令来更新我的配置:
git config --global submodule.recurse true
.gitconfig中的条目现在看起来像这样:
[submodule]
recurse = true
我的期望是,之后git pull
也将更新我的所有子模块。但是运行
git submodule update --init –recursive
再次在拉动之后仍然会更新一些子模块。
我是否误解了配置设置的效果,还是在某些情况下git pull仍无法更新子模块?
答案 0 :(得分:1)
您的问题是git pull
是否没有创建由pull引入的 new 子模块吗?如果是这样,那是一个已知的错误,请参见git help pull
;
BUGS
使用--recurse-submodules现在只能在已经签出的子模块中提取新的提交。当例如上游在超级项目的刚刚提取的提交中添加了一个新的子模块,该子模块本身无法被提取,因此无法在以后再次检出该子模块而不必再次进行提取。预计将在将来的Git版本中修复此问题。
答案 1 :(得分:0)
我复制了此内容,但没有发现问题。
制作子模块;
Horba@Horba MINGW64 ~/Source/Repos
$ mkdir MySubmodule
$ cd MySubmodule/
$ git init
Initialized empty Git repository in C:/Users/Horba/Source/Repos/MySubmodule/.git/
$ git commit --allow-empty -m "Init."
[master (root-commit) b54bb2d] Init.
设为遥控器;
Horba@Horba MINGW64 ~/Source/Repos
$ mkdir MyRemote
$ cd MyRemote/
$ git init
$ git commit -m "Init." --allow-empty
[master (root-commit) ce0c165] Init.
$ git submodule add ../MySubmodule/
Cloning into 'C:/Users/Horba/Source/Repos/MyRemote/MySubmodule'...
done.
warning: LF will be replaced by CRLF in .gitmodules.
The file will have its original line endings in your working directory.
$ git add -A
$ git commit -m "Add submodule."
[master d2cf903] Add submodule.
2 files changed, 4 insertions(+)
create mode 100644 .gitmodules
create mode 160000 MySubmodule
成为本地人;
Horba@Horba MINGW64 ~/Source/Repos
$ git clone --recurse-submodules MyRemote/ MyLocal
Cloning into 'MyLocal'...
done.
Submodule 'MySubmodule' (C:/Users/Horba/Source/Repos/MySubmodule) registered for path 'MySubmodule'
Cloning into 'C:/Users/Horba/Source/Repos/MyLocal/MySubmodule'...
done.
Submodule path 'MySubmodule': checked out 'b54bb2d8f459816dbe634f7e94af273aab9f29b9'
在子模块上做一些工作;
Horba@Horba MINGW64 ~/Source/Repos
$ cd MySubmodule/
$ git commit --allow-empty -m "Submodule work."
[master 4ce4c85] Submodule work.
更新远程子模块;
Horba@Horba MINGW64 ~/Source/Repos/MyRemote/MySubmodule (master)
$ git pull
remote: Counting objects: 1, done.
remote: Total 1 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (1/1), done.
From C:/Users/Horba/Source/Repos/MySubmodule
b54bb2d..4ce4c85 master -> origin/master
Updating b54bb2d..4ce4c85
Fast-forward
$ cd ..
$ git status
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: MySubmodule (new commits)
no changes added to commit (use "git add" and/or "git commit -a")
$ git add -A
$ git commit -m "Update submodule."
[master eef0abb] Update submodule.
1 file changed, 1 insertion(+), 1 deletion(-)
设置我们的配置选项;
Horba@Horba MINGW64 ~/Source/Repos/MyLocal (master)
$ git config --global submodule.recurse true
在本地拉动递归;
Horba@Horba MINGW64 ~/Source/Repos/MyLocal (master)
$ git pull
Updating ce0c165..eef0abb
Fast-forward
.gitmodules | 3 +++
MySubmodule | 1 +
2 files changed, 4 insertions(+)
create mode 100644 .gitmodules
create mode 160000 MySubmodule
Submodule path 'MySubmodule': checked out '4ce4c855986a56b5362c30b30ff4143d1d399f98'
$ gs
On branch master
Your branch is up to date with 'origin/master'.
nothing to commit, working tree clean