【问题标题】:adding a git submodule that tracks master添加一个跟踪 master 的 git 子模块
【发布时间】:2013-09-24 14:17:59
【问题描述】:

我正在使用 git 1.8.4 并尝试添加一个子模块来跟踪另一个存储库的主模块。我尝试按如下方式添加:

git submodule add -b master /path/to/myrepo.git

当我尝试添加它时出现以下错误

Cloning into 'myrepo.git'...
warning: You appear to have cloned an empty repository.
done.
fatal: Cannot update paths and switch to branch 'master' at the same time.
Did you intend to checkout 'origin/master' which can not be resolved as commit?
Unable to checkout submodule 'myrepo'

我不确定这是什么意思...有人可以解释一下吗?

【问题讨论】:

  • 你能不能尝试进入那个子模块,做一个git checkout -b master origin/master,回到一个级别,然后git submodule update --remote --init
  • 当我尝试第一个结帐命令致命时,我收到相同的消息消息:无法更新路径并同时切换到分支“主”。您是否打算签出无法解析为提交的“origin/master”?
  • 然后尝试,在子模块中:git branch -b master ; git reset --hard origin/master(如stackoverflow.com/a/17137740/6309)。但如果它仍然抱怨origin/master,那么该子模块的遥控器可能不正确。 git remote -v 返回什么?实际 repo /path/to/myrepo.git 中是否有 master 分支?
  • 我验证了实际的 repo 有一个 master 分支。当我在子模块目录中运行git remote -v 时,我得到origin /path/to/sub/module.git/ (fetch) origin /path/to/sub/module.git/ (push) 但仍然收到关于原始主机的相同错误
  • git branch -avvv 返回什么(在子模块中)?你在分支列表中看到origin/master 吗?

标签: git git-submodules


【解决方案1】:

子模块似乎没有分支的事实(即:“cd submodule ; git branch -avvv”没有返回任何内容,这意味着父 repo 中的子模块配置未正确初始化和更新。

commented:

前进的一种方法是从父 repo 的新克隆开始(不引用您的子模块),然后重复这些步骤:

git submodule add -b master /path/to/myrepo.git ; 
git submodule update --remote --init. –

【讨论】:

    猜你喜欢
    • 2017-07-23
    • 2012-02-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-03
    • 2011-02-19
    • 2017-10-21
    • 2010-11-08
    相关资源
    最近更新 更多