登陆到远程linux服务器上,使用git, clone的时候报“fatal: Unable to find remote helper for 'https'”错,没管,绕过,使用git clone git://....协议download下来项目。
但是到提交完要push回服务器的时候,必须得用https,搜了一下问题,是系统中没有curl,都是要装curl的,比如:
yum install curl-devel
或者apt-get等
但是问题来了,远程服务器上没有sudo到root的权限怎么办?
得自己安装curl,从curl - Download下载到最新的curl包:
解压,然后make并安装:
./configure --prefix=/home/{username}/curl/
make
make install
安装好后,再尝试git push,还是报一样的错。
想到应该需要重新编译并安装git,执行:
./configure --prefix=/home/{username}/git/ --with-curl=/home/{username}/curl/
注意这里一定要使用--with-curl参数,指定到上面安装的curl目录,git只有与curl库做link之后,才能使用https功能。
再次make & make install
git push成功。
本次解决问题的经验教训:
实际上是重新编译时先使用./configure --prefix=/home/{username}/git/未果后才思考的,执行./configure --prefix=/home/{username}/git/ &> config.log,把log重定向到这个文件里打开,搜curl,发现curl的状态是no,表明这个configure没有找到curl,那么自然后面在make的时候也就无法完成link,然后./configure -h,看到--with-curl参数,想起需要指定,才搞定问题。
经验教训是遇到问题还是要自己思考一下原理,网上搜的文章都是有root权限的前提下能装到系统默认位置的方案,没有想原理,另外要注意观察日志,帮助理解问题。
附安装git教程:
删除旧版本:
[root@localhost test1]# yum remove git
安装编译新版版本:
[root@localhost test1]# cd /usr/local/src/
[root@localhost test1]# wget https://www.kernel.org/pub/software/scm/git/git-2.15.1.tar.xz
[root@localhost test1]# tar -vxf git-2.15.1.tar.xz
[root@localhost test1]# cd git-2.15.1
[root@localhost test1]# make prefix=/usr/local/git all
[root@localhost test1]# make prefix=/usr/local/git install
[root@localhost test1]# echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/profile
[root@localhost test1]# source /etc/profile
[root@localhost test1]# git --version