现象

在Ubuntu 18.04上下载Android源码,遇到报错:git: ‘remote-https’ is not a git command。

$ repo init -u https://android.googlesource.com/platform/manifest -b master
Get https://gerrit.googlesource.com/git-repo/clone.bundle
Get https://gerrit.googlesource.com/git-repo
git: 'remote-https' is not a git command. See 'git --help'.

apt upgrade不能解决文件

使用apt命令升级git到最新版本,不能解决这个问题。

work-around

使用GitHub或者国内的git服务,用ssh方式的下载代码是可以的,HTTPS的方式会报同样的错误。

# ok
$ git clone git@github.com:git/git.git

# error
$ git clone https://github.com/git/git.git

solution

下载git源码,在本地编译:

$ git clone git@github.com:git/git.git
$ make

看网上说需要有libcurl4-openssl-dev这个包,才能编译出git-remote-https。我的电脑已经安装,不确定这个依赖是否必须。

编译完成后,生成文件:git-remote-https,复制到git命令所在目录(或者添加到path中)

$  ll git-remote-http*
-rwxrwxr-x 4 dev dev 12796440 3月  24 12:40 git-remote-https*
$ which git
/usr/local/bin/git
$ sudo cp git-remote-https /usr/local/bin/

再次下载代码,不再提示错误。

之前没有遇到过此类问题,不确定原因。不知道是否和Ubuntu版本有关。
知道原因的同学请提示一下。

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐