linux源码如何安装git

发布时间:2021-12-01 17:05:15 作者:小新
来源:亿速云 阅读:209

小编给大家分享一下linux源码如何安装git,希望大家阅读完这篇文章之后都有所收获,下面让我们一起去探讨吧!

linux源码安装git的方法:1、下载git源码上传至Linux服务器;2、登录目标机器,解压并安装;3、安装“gcc gcc-c++”;4、执行一下git的安装命令即可。

本文操作环境:linux5.9.8系统、git 2.9.5版、Dell G3电脑。

Linux 安装git/源码安装:

Git 安装

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

Linux 安装

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

源码安装

1. 下载源码

可以在另一台电脑中下载好源码,然后上传至Linux服务器

https://mirrors.edge.kernel.org/pub/software/scm/git/

找到对应的版本。

2. 上传至服务器

以git-2.9.5.tar.gz为例,将下载好的文件上传至服务器。

scp git-2.9.5.tar.gz  root@192.168.0.102:/home/tools

scp git-2.9.5.tar.gz 目标机器的用户@目标机器ip:目标机器路径

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的头文件, 开发包没装。安装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

若无报错则安装成功

6.检查git安装是否完成

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

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

7.配置环境变量

vi /etc/profile

编辑环境变量配置文件,在最后追加下面的字符串,指定bin目录的地址

export PATH=$PATH://home/Git/bin

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

source /etc/profile

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

看完了这篇文章,相信你对“linux源码如何安装git”有了一定的了解,如果想了解更多相关知识,欢迎关注亿速云行业资讯频道,感谢各位的阅读!

推荐阅读:
  1. php for Linux源码编译安装与配置方法
  2. linux源码安装iostat,dstat,systat的方法

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

linux git

上一篇:VB.NET NotifyIcon控件怎么用

下一篇:Java编程语言常见缺陷是什么

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》