解决repo sync ( git )报错: git: ‘remote-https‘ is not a git command

你的名字 2024-03-26 21:13 187阅读 0赞

现象

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

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

apt upgrade不能解决文件

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

work-around

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

  1. # ok
  2. $ git clone git@github.com:git/git.git
  3. # error
  4. $ git clone https://github.com/git/git.git

solution

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

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

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

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

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

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

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

发表评论

表情:
评论列表 (有 0 条评论,187人围观)

还没有评论,来说两句吧...

相关阅读