无法'git submodule foreach git pull` [英] Unable to `git submodule foreach git pull`

查看:300
本文介绍了无法'git submodule foreach git pull`的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题是基于这个线程

a>。



我的.gitmodules位于我的家中

  [submodulebin] 
path = bin
url = git://github.com/masi/bin.git

我的家庭中的文件夹 - 结构

 
| - [drwxr-xr-x] bin //这是我制作子模块
的文件夹//它也是一个文件夹,我有一个Git推我的子模块的文件
| - fileA
` - folderA
...

我运行

  git submodule init#我得不到这些命令的输出
git子模块更新

我运行

  git submodule foreach git拉

我得到

 输入'bin'
致命:您想从现在开始取什么?
停在'bin'处;脚本返回非零状态。

我的第一个修正错误的方法是改变 path = bin path = / Users / Masi / bin 。但是,这并不能解决问题。

如何从外部存储库(我的Git中的子模块)上载内容?

解决方案

这通常是没有远程配置时发生的错误。

(From
this thread



它是一个修补程序,至少可以修复在很久以前初始化的仓库中运行git pull时的回归,该仓库不使用.git / config文件指定远程仓库的位置。


更好的信息可能类似于: b $ b 没有为您当前的分支配置默认远程,


和默认的远程origin也没有配置。



我认为这个消息在之前的传球中错过了用户友好的方式,因为
到当时无法访问。







因此,此消息表明.git / modules中提到的远程回购没有在.git / config



git submodule

子模块不要与遥控器混淆,遥控器主要用于同一项目的分支机构;

子模块用于不同的项目喜欢构建源代码树的一部分,而两个项目的历史仍保持完全独立,并且不能从主项目中修改子模块的内容。

我相信你可能错过了 git submodule init 的步骤:

子模块init


初始化子模块, ie将.gitmodules中找到的每个子模块名称和URL注册到.git / config 中。
.git / config 中使用的键是 submodule。$ name.url

此命令不会改变.git / config中的现有信息。

然后您可以自定义子模块克隆URL在 .git / config 中进行本地设置并继续执行git子模块更新;如果您不打算自定义任何子模块位置,也可以使用 git子模块update --init ,而无需显式初始化步骤。


< blockquote>

如果您的远程仓库(在.git / modules中声明)在.git / config中被充分引用,则不应再有此错误消息。



在使用(pullin)子模块之前,步骤如下:

  git submodule init 
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?

解决方案

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 long time ago that does not use the .git/config file to specify where my remote repositories are.

a better message would probably be something like:

No default remote is configured for your current branch,
and the default remote "origin" is not configured either.

I think the message missed being made user-friendly in earlier passes due to being inaccessible at the time.


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

Initialize the submodules, i.e. register each submodule name and url found in .gitmodules into .git/config.
The key used in .git/config is submodule.$name.url.
This command does not alter existing information in .git/config.
You can then customize the submodule clone URLs in .git/config for your local setup and proceed to git submodule update; you can also just use git submodule update --init without the explicit init step if you do not intend to customize any submodule locations.

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:

git submodule init
git submodule update

remain necessary.

这篇关于无法'git submodule foreach git pull`的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆