And*_*imm 667 git git-submodules
我已经创建了一个带有子模块的git存储库.我能够告诉子模块本身更改其远程存储库路径,但我不知道如何告诉父存储库如何更改子模块的远程存储库路径.
如果我有点不幸并且必须手动操作,我不会感到惊讶,因为即使删除子模块也不容易.
Jim*_*uls 942
您应该只能编辑.gitmodules
文件以更新URL,然后运行git submodule sync
以反映对超级项目和工作副本的更改.
Pav*_*raj 137
这些命令将在命令提示符下完成工作,而不会更改本地存储库上的任何文件
git config --file=.gitmodules submodule.Submod.url https://github.com/username/ABC.git
git config --file=.gitmodules submodule.Submod.branch Development
git submodule sync
git submodule update --init --recursive --remote
Run Code Online (Sandbox Code Playgroud)
请查看博客中的屏幕截图:将GIT子模块更改为URL/Branch到同一存储库的其他URL /分支
Mat*_*son 110
简单来说,您只需要编辑.gitmodules文件,然后重新同步和更新:
通过git命令或直接编辑文件:
git config --file=.gitmodules -e
Run Code Online (Sandbox Code Playgroud)
要不就:
vim .gitmodules
Run Code Online (Sandbox Code Playgroud)
然后重新同步和更新:
git submodule sync
git submodule update --init --recursive --remote
Run Code Online (Sandbox Code Playgroud)
Ben*_*ers 67
什么对我有用(在Windows上,使用git版本1.8.3.msysgit.0):
git submodule init
和git submodule update
完成所有这些之后,一切都处于我期望的状态.我认为存储库的其他用户在更新时会有类似的痛苦 - 在提交消息中解释这些步骤是明智的!
Von*_*onC 65
实际上,2009年4月已提交补丁以澄清gitmodule
角色.
所以现在gitmodule文档还没有包括:
该
.gitmodules
文件位于git工作树的顶级目录中,是一个文本文件,其语法与linkgit:git-config 1的要求相匹配.
[新]:
由于此文件由Git管理,它跟踪项目子模块的+记录.
存储在此文件中的信息用作提示,以填充存储在项目配置文件中的记录的权威版本.
应该对配置文件进行用户特定记录更改(例如,考虑到由于网络情况导致的子模块URL的差异),同时应该传播要传播的记录更改(例如,由于子模块源的重定位而导致的+) .
这几乎证实了吉姆的答案.
如果你按照这个git子模块教程,你会看到你需要一个" git submodule init
"来将子模块存储库URL添加到.git/config.
2008年8月添加了 " git submodule sync
" ,以便在URL更改时更轻松地完成该任务(特别是如果子模块的数量很重要).
具有该命令的关联脚本非常简单:
module_list "$@" |
while read mode sha1 stage path
do
name=$(module_name "$path")
url=$(git config -f .gitmodules --get submodule."$name".url)
if test -e "$path"/.git
then
(
unset GIT_DIR
cd "$path"
remote=$(get_default_remote)
say "Synchronizing submodule url for '$name'"
git config remote."$remote".url "$url"
)
fi
done
Run Code Online (Sandbox Code Playgroud)
目标仍然是: git config remote."$remote".url "$url"
只需编辑.git/config文件即可.例如; 如果你有一个"通用"子模块,你可以在超级模块中执行此操作:
git config submodule.common.url /data/my_local_common
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
229299 次 |
最近记录: |