关于git:源码安装git

git 源码装置

重要:

yum install libcurl-devel

装置之前先装置这个,否则https 不能用

1. 下载源码
wget https://github.com/git/git/archive/refs/tags/v2.31.0.tar.gz
2. 解压
tar -zxvf v2.31.0.tar.gz
3.编译装置
cd v2.31.0
.configure -prefix=/usr/lcoal/

报错: 提醒没有 .configure

解决: 装置 autoconf 生成

yum install autoconf
autoconf
.configure -prefix=/usr/local/

报错: no acceptable C compiler found in $PATH 没有 C 编译器

解决: 装置 C 编译器

yum install gcc
.configure -prefix=/usr/local/
make && make install

报错: fatal error: zlib.h: No such file or directory 没有 zlib.h

解决: 装置zlib-devel

yum install zlib-devel
make && make install

呈现

 rm -f "$execdir/$p" && 
 if test -z ""; 
 then 
 test -n "" && 
 ln -s "$destdir_from_execdir_SQ/bin/git" "$execdir/$p" || 
 { test -z "" && 
 ln "$execdir/git" "$execdir/$p" 2>/dev/null || 
 ln -s "git" "$execdir/$p" 2>/dev/null || 
 cp "$execdir/git" "$execdir/$p" || exit; }; 
 fi 
done && 
remote_curl_aliases="" && 
for p in $remote_curl_aliases; do 
 rm -f "$execdir/$p" && 
 test -n "" && 
 ln -s "git-remote-http" "$execdir/$p" || 
 { test -z "" && 
 ln "$execdir/git-remote-http" "$execdir/$p" 2>/dev/null || 
 ln -s "git-remote-http" "$execdir/$p" 2>/dev/null || 
 cp "$execdir/git-remote-http" "$execdir/$p" || exit; } 
done && 
./check_bindir "z$bindir" "z$execdir" "$bindir/git-add"
​

大略这么一串,阐明胜利,cd 到装置门路

cd bin 
./git

当初阐明装置胜利,然而还不能在别处运行,咱们增加环境变量

4.配置环境变量

永恒配置环境变量有两种办法,一种是间接编辑 /etc/profile

vim /etc/profile

而后在最初追加

export PATH=$PATH:/usr/lcoal/soft/git/bin

间接编辑profile 文件是不好保护的,我采纳了另外一种办法

cd /etc/profile.d
vim git.sh

咱们在profile.d下新建一个脚本,profile配置文件中会读取这个文件夹下所有的sh,新建内容:

export GIT_HOME=/usr/local/soft/git
export PATH=$PATH:$GIT_HOME/bin

而后

source /etc/profile

失效,咱们测试一次写入的环境变量

echo $GIT_HOME
/usr/local/soft/git

环境变量失效,当初测试git

git version
git version 2.31.0

git 装置胜利,尽管yum install git 能够间接装置,然而版本太老,对centos 感兴趣的倡议源码装置,从中遇到问题,解决问题,能够学到很多的.

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理