1.安装前准备
最近github升级了,git clone https项目报错,镜像用的centos7.3,看样子原装的git1.8的版本低了。
报错信息:fatal: unable to access 'https://github.com/xxx':SSL connect error
GCC 用于编译安装包
# yum install gcc perl-ExtUtils-MakeMaker
再卸载CentOS自带的老版本git
# yum -y remove git
2.下载git并安装
# cd /usr/local/src # wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.17.0.tar.gz # tar xzf git-2.17.0.tar.gz # cd git-2.17.0 # make prefix=/usr/local/git all # make prefix=/usr/local/git install # ln -s /usr/local/git/bin/git /usr/bin/git
查看一下git的版本
# git --version git version 2.17.0
3.安装中遇到的问题
git-compat-util.h:283:25: fatal error: openssl/ssl.h: No such file or directory yum install openssl-devel -y http.h:6:23: fatal error: curl/curl.h: No such file or directory yum install curl-devel -y http-push.c:19:19: fatal error: expat.h: No such file or directory yum install expat-devel -y tclsh failed; using unoptimized loading MSGFMT po/de.msg make[1]: *** [po/de.msg] Error 127 yum install -y gettext ---------------------------------------------------------------------------- Gitlab error “fatal: The remote end hung up unexpectedly” the postBuffer size before trying to re-run the git push. Use the below command to set the postBuffer size to 100MB. git config --global http.postBuffer 524288000 git config --global ssh.postBuffer 524288000 http://www.jamescoyle.net/how-to/894-gitlab-error-fatal-the-remote-end-hung-up-unexpectedly 最后重启后恢复正常 git clone https报401错误: 在centos系统上下载git代码时出现以下错误: The requested URL returned error: 401 Unauthorized while accessing 网上查找资料说是git版本的问题,系统用yum install git安装的 版本是 1.7.1 ,要解决此问题要安装更高版本的git 解决方案: 1.下载git源码 wget https://www.kernel.org/pub/software/scm/git/git-1.9.4.tar.gz tar zxvf git-1.9.4.tar.gz cd git-1.9.4 ./autoconf ./configure --prefix=/usr/local make make出错了 Can't locate ExtUtils/MakeMaker.pm 解决这个错误方法是: yum install perl-ExtUtils-Embed -y wget https://github.com/git/git/archive/v2.2.1.tar.gz # cd git-2.1.2 # make prefix=/usr/local/git all # make prefix=/usr/local/git install # echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/bashrc # source /etc/bashrc make install 2.最后别忘了删掉旧的git,并把新版本的git建立软链接到/usr/bin/git # rm /usr/bin/git # ln -s /usr/local/bin/git /usr/bin/git 从GitHub网站clone代码时---- Unable to find remote helper for 'https' It looks like not having (lib)curl-devel installed when you install git can cause this. 解决方案: $ yum install curl-devel -y $ # cd to wherever the source for git is $ cd /home/lion/git-source-code $ ./configure $ make $ make install 2018/1/17 git pull error: The following untracked working tree files would be overwritten by merge: www/protected/api/models/xxx.php www/protected/api/models/xxc.php Please move or remove them before you merge. Aborting 解决方法: git clean -d -fx "vendor/huaqin/resource/3rdPart/aw700_default/system/thirdPart.mk" 其中 x -----删除忽略文件已经对git来说不识别的文件 d -----删除未被添加到git的路径中的文件 f -----强制运行 如果希望保留生产服务器上所做的改动,仅仅并入新配置项: git stash git pull git stash pop 然后可以使用git diff -w +文件名 来确认代码自动合并的情况. 如果希望用代码库中的文件完全覆盖本地工作版本. 方法如下: git reset --hard git pull error: Untracked working tree file 'public/images/icon.gif' would be overwritten by merge. 1. git reset --hard HEAD 2. git clean -f -d 3. git pull 有时排查各种原因还是有错误,直接重启后就好了,重启治百病。