Git 从现有存储库将子模块添加到超级项目
我在一个目录中有几个(大约 10-15 个)Git 存储库:
~/plugins/admin
~/plugins/editor
~/plugins/etc
每个存储库都有自己独立的存储库和远程服务器。
问题是,要从所有存储库中提取所有更改,我必须:
cd ~/plugins/admin
git pull origin master
password: ********
cd ..
cd ~/plugins/editor
git pull origin master
password: ********
cd ..
cd ~/plugins/etc
git pull origin master
password: ********
cd ..
如何设置 Git 子模块以使用 1 个命令提取所有存储库,
或者为 Windows、Linux 和 Mac 编写一个脚本(因为我使用所有 3 个命令)操作系统)来有效地做同样的事情。请记住,存储库可以位于不同的分支上,并且不一定具有跟踪分支设置。
相同的注释:
- 所有存储库的密码都是相同的
- 远程服务器是相同的存储库(显然在单独的存储库/目录中)
- 我只想输入一次密码
- 我只想输入一个命令来提取所有存储库
- 公钥/私钥不是
- 我通过 ssh 连接到远程的选项
I have several (about 10-15) Git repositories in a directory:
~/plugins/admin
~/plugins/editor
~/plugins/etc
Each have their own separate repository and remote server.
The problem is that to pull all the changes from all the repositories I have to:
cd ~/plugins/admin
git pull origin master
password: ********
cd ..
cd ~/plugins/editor
git pull origin master
password: ********
cd ..
cd ~/plugins/etc
git pull origin master
password: ********
cd ..
How can I setup either Git submodules to pull all the repositories with 1 command,
OR alternatively write a script for Windows, Linux and Mac (as I use all 3 operating systems) to effectively do the same thing. Keeping in mind that the repos can be on different branches and don't necessarily have a tracking branch setup.
Same notes:
- The password is the same for all repos
- The remote server is the same repos (obviously in seperate repos/directories)
- I only want to type the password in once
- I only want to type one command to pull all repos
- Public/private keys are not an option
- I'm connecting to the remote via ssh
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
当您尝试从某些 git 存储库已存在的位置添加子模块时,该存储库将添加到 index.html 中。
when you're trying to add submodule from place where some git repo already exists this repo will be added in index.
使用 Perl,就像 Git 一样。假设您有每个密码:
通过一些额外的改进,您可以添加更好的错误处理和一次读取密码,而不是每次。
Use Perl, just as Git does. Assuming you have the password for each:
With a little additional polish you could add better error handling and reading the password once, rather than each time.
(我知道这个问题很老了,但也许我的回答对某人有用。)
现在你可以使用 git submodule foreach 来完成这样的任务。
也许 git pull git pull --recurse-submodules=yes 也可以帮助你
(I know that this question very old, but maybe my reply will be useful for someone.)
Nowadays you can use git submodule foreach for such task.
And maybe git pull git pull --recurse-submodules=yes also can help you