为什么即使我在 Ubuntu 12.10 上安装了 git 1.8.3.2,`git subtree` 也不起作用?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17797328/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 08:48:48  来源:igfitidea点击:

Why is the `git subtree` not working even though I have git 1.8.3.2 installed on Ubuntu 12.10?

gitubuntugit-subtree

提问by Tobias J

I am about to deploy my AngularJS based static site as a Github Page with Yeoman. Step 3 of the deployment instructions tell me to do

我即将使用 Yeoman 将我的基于 AngularJS 的静态站点部署为 Github 页面。部署说明的第 3 步告诉我要做

git subtree push --prefix dist origin gh-pages

git subtree push --prefix dist origin gh-pages

but when I enter that I get

但是当我输入时,我得到

git: 'subtree' is not a git command. See 'git --help'.

git: 'subtree' is not a git command. See 'git --help'.

This SO answer provided me instructionson how to upgrade to the latest git-core and ensure it always get upgraded to the latest stable release.

这个SO answer 为我提供了有关如何升级到最新的 git-core 并确保它始终升级到最新的稳定版本的说明。

sudo add-apt-repository ppa:git-core/ppa
sudo apt-get update
sudo apt-get install git

After running those commands I did git --versionto make sure I had the latest version and apparently I did since git version 1.8.3.2was the output. Now when I tried running

运行这些命令后,我git --version确保我拥有最新版本,显然我这样做了,因为这git version 1.8.3.2是输出。现在当我尝试跑步时

git subtree push --prefix dist origin gh-pages

git subtree push --prefix dist origin gh-pages

again I still got the same following error

再次我仍然遇到相同的以下错误

git: 'subtree' is not a git command. See 'git --help'.

git: 'subtree' is not a git command. See 'git --help'.

Finally I just restarted Ubuntu 12.10 and tried to run the command again but once again, I got the same error.

最后,我重新启动了 Ubuntu 12.10 并尝试再次运行该命令,但再次出现相同的错误。

How come the git subtreecommand is still not working even though I have upgraded to the current stable release?

git subtree即使我已升级到当前的稳定版本,该命令为什么仍然不起作用?

采纳答案by TeTeT

It doesn't seem to be installed by the default package. This site has some directions: http://engineeredweb.com/blog/how-to-install-git-subtree

它似乎没有被默认包安装。这个网站有一些说明:http: //engineeredweb.com/blog/how-to-install-git-subtree

回答by Tobias J

It actually is installed on Ubuntu but for some reason it's not put anyplace where git can find it. Easiest way is to create a symlink:

它实际上安装在 Ubuntu 上,但由于某种原因,它没有放在 git 可以找到它的任何地方。最简单的方法是创建一个符号链接:

sudo chmod +x /usr/share/doc/git/contrib/subtree/git-subtree.sh
sudo ln -s /usr/share/doc/git/contrib/subtree/git-subtree.sh /usr/lib/git-core/git-subtree

UPDATE 1:looks like a patch has been submittedupstream to fix this but it hasn't yet been merged.

更新 1:看起来上游已提交补丁来解决此问题,但尚未合并。

UPDATE 2:the patch to fix this in Debian has been merged, but since they went the route of a separate git-subtreepackage I don't think this will make it to Ubuntu 12.04. Seems to not be an issue in 14.04 as /usr/lib/git-core/git-subtreeis already created correctly by the gitpackage.

更新 2:在 Debian 中修复此问题的补丁已合并,但由于它们采用单独git-subtree软件包的方式,我认为这不会适用于 Ubuntu 12.04。在 14.04 中似乎不是问题,因为包/usr/lib/git-core/git-subtree已经正确创建了git

回答by Alex F

On Fedora, it is available as a separate package:

在 Fedora 上,它作为一个单独的包提供:

dnf install git-subtree

dnf install git-subtree