git 子模块 foreach 不工作
我想弄清楚为什么 git submodule foreach 命令对我不起作用。我克隆了一个 git 存储库,它有几个子模块。我想立即初始化并更新所有子模块以获取子模块源。但是无论我尝试 git submodule foreach 都不适合我...我尝试了几件事:
git submodule foreach init
git submodule foreach update
git submodule foreach update --init
git submodule foreach --recursive git submodule update --init
每个命令都会执行但没有任何输出...如果我单独初始化/更新每个模块(不使用 foreach)那么就没问题。
有什么想法吗?
I want to figure out why git submodule foreach
command is not working for me. I have cloned a git repository which has several submodules. I wanted to init and update all submodules at once to pull down the submodules sources. But whatever I try git submodule foreach is not working for me... I tried several things:
git submodule foreach init
git submodule foreach update
git submodule foreach update --init
git submodule foreach --recursive git submodule update --init
Every command will execute but without any output... If I go and init/update each module separately (without using foreach) then no problem.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
git submodule init
或git submodule update
应该适用于.gitmodules
中注册的所有子模块,所以它不为每个子模块执行它们是没有意义的。如果子模块中有子模块,
git submodule update --recursive
将递归地处理所有子模块。git submodule init
orgit submodule update
are supposed to work for all submodules registered in.gitmodules
, so it doesn't make sense to execute them for each submodules.If you had submodules within submodules,
git submodule update --recursive
would take care of all submodules recursively.克隆后,您通常需要做的就是:
最初完成此操作后,删除 --init 选项。
init 选项是将 .gitmodules 文件中指定的 url 复制到子模块存储库配置中的命令的一部分。如果您正在使用选择的特定遥控器并且项目已转移到您不想使用的遥控器,您可能不想执行此操作。一种典型的情况是,当您更愿意使用 GitHub 上的项目分支并且顶级存储库指向主存储库时。
After a clone all you usually need to do is:
After this is done initially, you drop the --init option.
The init option is the part of the command that copies the url specified in the .gitmodules file down into the submodule repo configuration. You may not want to do this if you are using a particular remote of choice and the project has move to one you don't want to use. A typical case of this is when you would rather use your fork of a project on GitHub and the top level repo points to the main one.
你必须运行:
--
你需要在树的根部有一个 .gitmodules 文件,它看起来像这样。
根据上述内容,输出应如下所示:
You have to run:
--
You need a .gitmodules file at the root fo your tree, it looks like this.
Here's how the output should look based on the above: