资源:git-2.9.5 ,多版本下载地址,这个页面的下载可能很慢,可以试下这里
1.解压文件
tar -zxvf git-2.9.5.tar.gz
2.进入git-2.9.5,使用configure,生成Makefile文件
./configure --prefix=/usr/local/git295
常用配置项
--prefix= :指定安装的路径
--sysconfdir= :指定配置文件目录
--enable-feature :启用某个特性
--disable-fecture :禁用特性
--with-function :启用某功能
--with-php-config=/usr/local/php/bin/php-config :例如安装php扩展时启用php配置文件
--without-function :禁用某功能
3.执行make,从Makefile中读取指令,将源码编译成二进制目标文件,并存放在当前目录下,如果之前有执行过make,存留了旧的目标文件*.o,要先使用 make clean 进行清除再使用make
make
4.执行make install 进行安装
make install
5.设置全局可直接使用git命令:通过软连接将安装目录下的bin/git引用到/usr/local/bin下
ln -s /usr/local/git295/bin/git /usr/local/bin/git
6.首次使用git commit时,会提示 git config --global user.email "you@example.com" git config --global user.name “Your Name” ,要求设置用户信息(用户信息值可以自定义设置,没有要求),为了避免覆盖机器上其他用户的设置,不要用全局设置,去掉–global 配置项即可
git config user.email "user1@test1.com"
git config user.name "user1@test1"
操作完后,查看到.git/config配置文件中被自动添加了[user]值
[user]
email = user1@test1.com
name = user1@test1