git 源码装置
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 vv2.31.0.configure -prefix=/usr/lcoal/
报错: 提醒没有 .configure
解决: 装置 autoconf 生成
yum install autoconfautoconf.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-develmake && 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.dvim git.sh
咱们在profile.d下新建一个脚本,profile配置文件中会读取这个文件夹下所有的sh,新建内容:
export GIT_HOME=/usr/local/soft/gitexport PATH=$PATH:$GIT_HOME/bin
而后
source /etc/profile
失效,咱们测试一次写入的环境变量
echo $GIT_HOME/usr/local/soft/git
环境变量失效,当初测试git
git versiongit version 2.31.0
git 装置胜利,尽管yum install git 能够间接装置,然而版本太老,对centos 感兴趣的倡议源码装置,从中遇到问题,解决问题,能够学到很多的.