Error: "git: 'submodule' is not a git command" on Intel Edison and git 2.0.1

Error: "git: 'submodule' is not a git command" on Intel Edison and git 2.0.1

当我尝试使用 git 子模块并在我的 Intel Edison 运行 Yocto Linux 和 git 2.0.1 上键入常用命令 git submodule 时,我刚收到以下错误消息:

$> git submodule init
git: 'submodule' is not a git command. See 'git --help'

系统版本为:

$> uname -r
3.10.17-poky-edison+
$> git --version
git version 2.0.1
$> configure_edison --version
159

google 上没有该错误的踪迹。

是否有额外的软件包要安装?还是因为 git 2.0.1 ?

在我的 Ubuntu (git 1.9.1) 上,这些命令工作正常。

是的,Edison 上的 Git 可能是轻量级版本。正如 msw 在评论中提到的,最好的选择是从 source 构建 git。但我相信下一个版本的 Yocto 包可能会附带一个新版本的 git.

这个问题很老了,但我在爱迪生板上遇到了同样的问题,这是我的解决方法,它可能仍然会让一些人感兴趣。
我为爱迪生使用的 yocto 版本是这个:https://github.com/edison-fw/meta-intel-edison

问题的发生是因为爱迪生板上的git版本缺少一些零件。在这种情况下,git-submodules 二进制文件在 /usr/libexec/git-core

中丢失

因此,一旦您按照上面相同 link(或此处 https://edison-fw.github.io/meta-intel-edison/)中的说明构建了 yocto 映像并刷新了您的电路板,您将必须复制文件 git-submodules 从你的主机到你的爱迪生板。

在您的主机上,一旦进入您的构建目录 (path/to/edison/out/linux64/build),键入:

find . -name "git-submodule"

并且您将获得同一文件的不同位置。来一份吧。

在爱迪生板上复制到/usr/libexec/git-core。

现在带有子模块的 git 应该可以工作了...


更新:
渡轮的回答更好,但在某些方面它对我这边不起作用(yocto sumo)。软件包 git-perltoolsgit 软件包的一部分,因此无需将其添加到您的 core-image,但它仍未安装。我发现包 git-perltools 取决于要安装的 findutils,因此可能需要将 findutils 添加到 core-image 才能使 Ferry 的回答生效。

注意:
我更愿意评论渡轮的回答,但我没有权利。

使用 Yocto 构建 git 时,行为符合预期。不幸的是,预期的行为不是您所期望的。在 Ubuntu 上,git-submodule 包含在包 git 中,在 Yocto 上包含在包 git-perltools 中。当你 运行 bitbake git 构建以下包时(Thud):

ferry@delfion:~/.../out/linux64/build/tmp/work/corei7-32-poky-linux/git/2.18.1-r0/deploy-debs/corei7-32$ ls -l
- git_2.18.1-r0_i386.deb
- git-bash-completion_2.18.1-r0_i386.deb
- git-dbg_2.18.1-r0_i386.deb
- git-dev_2.18.1-r0_i386.deb
- git-doc_2.18.1-r0_i386.deb
- git-perltools_2.18.1-r0_i386.deb
- gitweb_2.18.1-r0_i386.deb

with git-perltools 包含 git-submodule.

你怎么能提前知道?签出 https://layers.openembedded.org. You can easily find: http://cgit.openembedded.org/openembedded-core/tree/meta/recipes-devtools/git/git.inc?h=thud,其中包含:

PERLTOOLS = " \
    ${libexecdir}/git-core/git-add--interactive \
    ${libexecdir}/git-core/git-archimport \
    ${libexecdir}/git-core/git-cvsexportcommit \
    ${libexecdir}/git-core/git-cvsimport \
    ${libexecdir}/git-core/git-cvsserver \
    ${bindir}/git-cvsserver \
    ${libexecdir}/git-core/git-difftool \
    ${libexecdir}/git-core/git-send-email \
    ${libexecdir}/git-core/git-svn \
    ${libexecdir}/git-core/git-instaweb \
    ${libexecdir}/git-core/git-submodule \
    ${libexecdir}/git-core/git-am \
    ${libexecdir}/git-core/git-request-pull \
    ${datadir}/gitweb/gitweb.cgi \
    ${datadir}/git-core/templates/hooks/prepare-commit-msg.sample \
    ${datadir}/git-core/templates/hooks/pre-rebase.sample \
    ${datadir}/git-core/templates/hooks/fsmonitor-watchman.sample \
"

# Git tools requiring perl
PACKAGES =+ "${PN}-perltools"
FILES_${PN}-perltools += " \
    ${PERLTOOLS} \
    ${libdir}/perl \
    ${datadir}/perl5 \
"

因此,不仅将 git 添加到 core-image,还将 git-perltools 添加到您的 core-image 中,您将得到您想要的以及更多。

OTOH Yocto 有一个很好的功能,可以在您的主机上构建一个交叉编译器环境。所以你可以配置使用f.i。 QT Creator 使用 sdk 构建并从您的主机远程调试目标。这样您就不需要 build/install 英特尔爱迪生上的工具链。更多相关信息:https://edison-fw.github.io/meta-intel-edison/3-Building-the-SDK.html

Ferry Toth(又名 htot@github)