linux-centos 源码安装git

Git 安装

这里就不记录Windows/Mac OS系统的了,直接下载对应的安装程序,按步骤安装即可。

Linux 安装

登陆https://git-scm.com/download/linux

源码安装

1. 下载源码

[wujun@localhost ~]$ wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.24.0.tar.gz

2.创建Git家目录

mkdir Git

3. 解压并安装

登陆目标机器,解压并安装。/home/Git是指的安装目录

tar -zxvf git-manpages-2.9.5.tar.gz
cd git-2.9.5
[root@localhost git-2.9.5]# ./configure  --prefix=/home/Git
[root@localhost git-2.9.5]# make && make install

4. ./configure 报错

[root@localhost git-2.9.5]# ./configure  --prefix=/home/Git
configure: Setting lib to 'lib' (the default)
configure: Will try -pthread then -lpthread to enable POSIX Threads.
configure: CHECKS for site configuration
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/home/tools/git-2.9.5':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details

我的linux服务器执行报错中看出,gcc,cc,cl.exe为no。gcc是Linux的c语言编译器,说明我的机器中没有安装这些编译器。 分别安装以下gcc,gcc-c++,安装成功之后在执行一下git的安装命令

  [root@localhost git-2.9.5]# yum install gcc
  [root@localhost git-2.9.5]# yum install gcc-c++
  [root@localhost git-2.9.5]# ./configure  --prefix=/home/Git

5. make命令报错

[root@localhost git-2.9.5]# make && make install
    * new build flags
    CC credential-store.o
In file included from credential-store.c:1:0:
cache.h:40:18: 致命错误:zlib.h:没有那个文件或目录
 #include <zlib.h>
                  ^
编译中断。
make: *** [credential-store.o] 错误 1

缺少 zlib的头文件, 开发包没装。

另一种安装方法不需要configure

make prefix=/home/Git all都编译下

make prefix=/home/Git install

  • 安装zlib
    [root@localhost git-2.9.5]# yum install zlib
    [root@localhost git-2.9.5]# yum install zlib-devel
    [root@localhost git-2.9.5]# yum install perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker
    [root@localhost git-2.9.5]# make && make install
    
    若无报错则安装成功
  • 安装成功后显示最后内容:
  •         rm -f "$execdir/$p" && \
            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; } \
    done && \
    remote_curl_aliases="git-remote-https git-remote-ftp git-remote-ftps" && \
    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"

6.检查git安装是否完成

进入之前指定的安装目录,查看git版本,能成功则表示git安装完成

[root@localhost bin]# cd /home/Git/bin
[root@localhost bin]# ./git --version
git version 2.24.0

7.配置环境变量

vi /etc/profile

编辑环境变量配置文件,在最后追加下面的字符串,指定bin目录的地址 export PATH=$PATH://home/Git/bin

修改完成之后,执行命令,生效配置文件

source /etc/profile

检查是否配置成功,可切换路径到其他目录中,执行 git --version。返回git版本则表示环境变量配置完成。

8.fatal: Unable to find remote helper for 'https'

如果出现clone报错的问题。

yum install curl-devel
cd /home/tools/git-2.9.5/
./configure
make
make install

再次尝试一下clone。不行则重启一下

reboot

mkdir gitrepo 创建git资源仓库,cd gitrepo   mkdir project1    cd project1   git  init  --bare初始化project1的仓库

git clone ssh://wujun@192.168.1.100:22/home/wujun/gitrepo/myproject

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值