【发布时间】:2017-06-21 01:43:57
【问题描述】:
原始的.gitmodules 文件使用硬编码的https url,但对于一些自动化测试,我从ssh 克隆,并使子模块url 与../ModuleName 中的相对应。我也不想将这些更改推回 repo。
# change the https://github.com/ with git@github.com:
sed -i 's/https:\/\/github.com\//git@github.com:/g' ".git/config"
# delete the url lines from the submodule blocks of .git/config
sed -i '/submodule/ {$!N;d;}' ".git/config"
# change hardcoded https:// urls of submodules to relative ones
sed -i 's/https:\/\/github.com\/ProjName/../g' ".gitmodules"
# also make the same change in the .git/modules/*/config
sed -i 's/https:\/\/github.com\/ProjName/../g' .git/modules/*/config
# sync and update
git submodule sync
git submodule update --init --recursive --remote
使用上面的 sn-p,它可以满足我的需求。然而,烦人的是,.git/modules/ 文件夹似乎不受版本控制,但如果我只是删除它,git submodule sync 和大多数其他 Git 操作就会停止工作。
有没有办法在修改.gitmodules 和.git/config 文件后重新生成.git/modules?
【问题讨论】:
标签: git git-submodules