Git:fatal: unable to find remote helper for 'https'

Git:fatal: unable to find remote helper for ‘https’

复现
test1280 $ git clone https://github.com/go-chassis/go-chassis
Cloning into 'go-chassis'...
fatal: unable to find remote helper for 'https'
test1280 $ echo $PATH
/home/test1280/git/bin:/home/test1280/git/libexec/git-core:/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/test1280/bin

已知 git/bin 以及 git/libexec/git-core 均在 PATH 中。

查看 git/libexec/git-core 发现其中没有 git-remote-https 可执行文件。


解决

1)下载 libcurl 安装包(https://curl.haxx.se/download.html)

2)安装 libcurl 开发包

test1280 $ ./configure --prefix=$HOME/libcurl
checking whether to enable maintainer-specific portions of Makefiles... no
checking whether make supports nested variables... yes
checking whether to enable debug build options... no
……
test1280 $ make && make install
Making all in lib
make[1]: Entering directory `/home/test1280/curl-7.64.0/lib'
make  all-am
make[2]: Entering directory `/home/test1280/curl-7.64.0/lib'
  CC       libcurl_la-file.lo
……

安装 libcurl 库成功。

3)重新编译 git

test1280 $ ./configure --prefix=$HOME/git --without-tcltk --with-curl=$HOME/libcurl
configure: Setting lib to 'lib' (the default)
configure: Will try -pthread then -lpthread to enable POSIX Threads.
configure: CHECKS for site configuration
checking for gcc... gcc
……

好吧,还是有问题:

test1280 $ make
make: curl-config: Command not found
    LINK git-http-fetch
http.o: In function `fill_active_slots':
/home/test1280/git-2.20.1/http.c:1346: undefined reference to `curl_easy_cleanup'
……

4)查阅 git configure 帮助

test1280 $ cd $HOME/git-2.20.1
test1280 $ ./configure --help
`configure' configures git 2.20.1 to adapt to many kinds of systems.

Usage: ./configure [OPTION]... [VAR=VALUE]...
……
  --with-curl             support http(s):// transports (default is YES)
                          ARG can be also prefix for curl library and headers
  --with-expat            support git-push using http:// and https://
                          transports via WebDAV (default is YES)
                          ARG can be also prefix for expat library and headers
……
–with-curl默认此选项是YES,但是执行 configure 时却被认为没有libcurl库。
test1280 $ ./configure --prefix=$HOME/git --without-tcltk --with-curl | grep curl
checking for curl_global_init in -lcurl... yes
checking for curl-config... no
没找到 curl-config 命令,被 configure 认为没有安装 libcurl 库,不带 libcurl 编译。
test1280 $ which curl
/usr/bin/curl
test1280 $ whicu curl-config
-bash: whicu: command not found

5)指向自己的 curl-config

虽然 $PATH 没有找到 curl-config 命令,但是别忘了我们刚刚安装了 libcurl 包在 $HOME/libcurl 。

test1280 $ ll $HOME/libcurl/bin
total 220
-rwxr-xr-x 1 test1280 test1280 213675 Mar  6 21:33 curl
-rwxr-xr-x 1 test1280 test1280   5476 Mar  6 21:33 curl-config
test1280 $ echo "export PATH=$HOME/libcurl/bin:$PATH" >> ~/.bash_profile 
test1280 $ source ~/.bash_profile 
test1280 $ ./configure --prefix=$HOME/git --without-tcltk --with-curl=$HOME/libcurl | grep curl
configure: Setting CURLDIR to /home/test1280/libcurl
checking for curl_global_init in -lcurl... yes
checking for curl-config... curl-config
configure: Setting CURL_LDFLAGS to '-L/home/test1280/libcurl/lib -lcurl'
要让 git 的 configure 能找到 curl-config 命令以及相关头文件、库文件,带 libcurl 编译

6)重新编译 git

test1280 $ ./configure --prefix=$HOME/git --without-tcltk --with-curl=$HOME/libcurl && make && make install
configure: Setting lib to 'lib' (the default)
configure: Will try -pthread then -lpthread to enable POSIX Threads.
configure: CHECKS for site configuration
checking for gcc... gcc
checking for C compiler default output file name... a.out
……

7)成功运行

test1280 $ which git-remote-https
~/git/libexec/git-core/git-remote-https
test1280 $ git clone https://github.com/go-chassis/go-chassis
Cloning into 'go-chassis'...
remote: Enumerating objects: 85, done.
remote: Counting objects: 100% (85/85), done.
remote: Compressing objects: 100% (71/71), done.
在 git-core 目录中新增 git-remote-https 可执行文件,并已支持 git https 形式 clone 啦!

其实第三步是正确的,但是由于 git 的 configure 也检测 curl-config 命令但是找不到,

于是最后生成的 makefile 指定不带 libcurl 编译,无法生成 git-remote-https 。


相关:

1.https://blog.csdn.net/test1280/article/details/87868144

参考:

1.https://blog.csdn.net/zhezhebie/article/details/78035979
2.http://www.bubuko.com/infodetail-659524.html
3.https://blog.csdn.net/fenggms/article/details/83051423
4.https://stackoverflow.com/questions/8329485/unable-to-find-remote-helper-for-https-during-git-clone

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值