无法“git submodule foreach git pull”
这个问题基于此线程。
我的 .gitmodules 位于我的家
[submodule "bin"]
path = bin
url = git://github.com/masi/bin.git
我家的文件夹结构:
~
|-- [drwxr-xr-x] bin // this is the folder which I make a submodule
// it is also a folder where I have a Git to push my submodule's files
| -- fileA
` -- folderA
...
我运行
git submodule init # I get no output from these commands
git submodule update
我运行
git submodule foreach git pull
我得到
Entering 'bin'
fatal: Where do you want to fetch from today?
Stopping at 'bin'; script returned non-zero status.
我修复错误的第一个假设是更改 path = bin
到 path = /Users/Masi/bin
。 然而,这并不能解决问题。
如何从作为我的 Git 子模块的外部存储库上传内容?
This question is based on this thread.
My .gitmodules is at my Home
[submodule "bin"]
path = bin
url = git://github.com/masi/bin.git
My folder -structure at my Home:
~
|-- [drwxr-xr-x] bin // this is the folder which I make a submodule
// it is also a folder where I have a Git to push my submodule's files
| -- fileA
` -- folderA
...
I run
git submodule init # I get no output from these commands
git submodule update
I run
git submodule foreach git pull
I get
Entering 'bin'
fatal: Where do you want to fetch from today?
Stopping at 'bin'; script returned non-zero status.
My first assumption to fix the bug was to change path = bin
to path = /Users/Masi/bin
. However, this does not solve the problem.
How can you upload the content from the external repository which is a submodule in my Git?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这通常是没有配置远程时发生的错误。
(来自此线程)
这是一个至少修复了问题的补丁在很久以前初始化的存储库中运行“git pull”时的回归,该存储库不使用 .git/config 文件来指定我的远程存储库所在的位置。
因此,此消息表明 .git/modules 中提到的远程存储库未在 .git/config 中声明
git submodule
子模块不要与远程模块混淆,远程模块主要用于同一项目的分支;
子模块适用于您想要成为源代码树一部分的不同项目,而两个项目的历史记录仍然完全独立,并且您无法从主项目中修改子模块的内容。
我相信你可能错过了
git submodule init
这一步:submodule init
如果您的远程存储库(在 .git/modules 中声明)在 .git/config 中得到了充分引用,则不应再出现此错误消息。
在使用(拉动)子模块之前,以下步骤
仍然是必要的。
注意:Git 2.42(2023 年第 3 季度)重写了向
submodule..update
配置变量提供自定义命令的描述。请参阅 提交 7cebc5b(2023 年 7 月 25 日),作者:Petar Vutov (
pvutov
)。(由 Junio C Hamano --
gitster
-- 合并于 提交 a53e8a6,2023 年 8 月 4 日)git 子模块
现在包含在其 手册页:This is normally the error made when there is no remote configured.
(From this thread)
It was a patch introduced to at least fixes the regression when running "git pull" in a repository initialized a long time ago that does not use the
.git/config
file to specify where my remote repositories are.So this message indicates the remote repo mentioned in .git/modules is not declared in .git/config
From git submodule
Submodules are not to be confused with remotes, which are meant mainly for branches of the same project;
submodules are meant for different projects you would like to make part of your source tree, while the history of the two projects still stays completely independent, and you cannot modify the contents of the submodule from within the main project.
I believe you may have missed the step of
git submodule init
:submodule init
If your remote repo (declared in .git/modules) is adequately referenced in .git/config, you should not have this error message anymore.
Before using (pullin) submodules, the steps:
remain necessary.
Note: Git 2.42 (Q3 2023) rewrites the description of giving a custom command to the
submodule.<name>.update
configuration variable.See commit 7cebc5b (25 Jul 2023) by Petar Vutov (
pvutov
).(Merged by Junio C Hamano --
gitster
-- in commit a53e8a6, 04 Aug 2023)git submodule
now includes in its man page: