代码之家  ›  专栏  ›  技术社区  ›  Léo Léopold Hertz 준영

无法`git子模块foreach git pull`

  •  6
  • Léo Léopold Hertz 준영  · 技术社区  · 16 年前

    this thread .

    我的.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

    1 回复  |  直到 8 年前
        1
  •  5
  •   VonC    16 年前

    这通常是未配置远程时发生的错误。
    (来自 this thread )

    这是一个补丁,至少修复了在很久以前初始化的存储库中运行“git pull”时的回归问题,该存储库不使用 .git/config 文件以指定我的远程存储库的位置。

    更好的信息可能是这样的:

    当前分支没有配置默认远程,也没有配置默认的远程“源”。

    我认为,由于当时无法访问,该消息在早期版本中没有变得用户友好。


    因此,此消息表示.git/modules中提到的远程仓库未在.git/config中声明

    git submodule

    子模块不要与远程模块混淆,远程模块主要用于同一项目的分支;
    子模块适用于您希望成为源代码树一部分的不同项目,而这两个项目的历史仍然完全独立,您不能在主项目中修改子模块的内容。

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

    子模块初始化

    初始化子模块, 即将.gtmodules中的每个子模块名称和url注册到.git/config中 .
    使用的密钥 .git/config submodule.$name.url .
    此命令不会更改.git/config中的现有信息。
    然后,您可以在中自定义子模块克隆URL .git/config git submodule update ;您也可以直接使用 git submodule update --init

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

    在使用(pullin)子模块之前,请执行以下步骤:

    git submodule init
    git submodule update
    

    仍然是必要的。


    注意:Git 2.42(2023年第3季度)重写了向 submodule.<name>.update 配置变量。

    commit 7cebc5b (2023年7月25日) Petar Vutov ( pvutov ) .
    (已合并 Junio C Hamano -- gitster -- commit a53e8a6 ,2023年8月4日)

    doc :强调这一点 .gitmodules 不支持 !command

    签字人:佩塔尔·武托夫

    Bug修复 fc01a5d (“子模块更新文档:不要重复自己”,2016-12-27,Git v2.12.0-rc2-- merge ).

    custom command none .git模块 而另一个则不是。

    重写自定义命令的描述,使其更精确,并使读者更容易注意到自定义命令不能在 .git模块 文件。

    git submodule 现在包括在其 man page :

    它还将复制以下值 submodule.$name.update ,如果存在于 这 .git模块 文件,到 .git/config 更改现有信息 .git/config 以及(2) 设置为自定义命令的是 出于安全原因而复制。

    然后,您可以在中自定义子模块克隆URL .git/config

        2
  •  1
  •   Léo Léopold Hertz 준영    16 年前
        3
  •  0
  •   Léo Léopold Hertz 준영    16 年前
    推荐文章