Oracle Enterprise Linux中安装git

最近开始学习git,由于Oracle Enterprise Linux中git的自带版本比较低(1.7.1),以下是升级过程中遇到的一些问题并解决。

1.卸载旧版本的git

[root@DB Downloads]# git --version
git version 1.7.1
[root@DB Downloads]# yum remove git

2.安装git

尝试用yum来安装,但是发现下载的还是1.7.1

[root@DB Downloads]# yum install git
······
================================================================================
 Package        Arch         Version              Repository               Size
================================================================================
Installing:
 git            x86_64       1.7.1-9.el6_9        public_ol6_latest       4.6 M
Installing for dependencies:
 perl-Git       noarch       1.7.1-9.el6_9        public_ol6_latest        28 k

Transaction Summary
================================================================================
······ 
最后决定用源码来安装

参考1:https://git-scm.com/book/zh/v2/%E8%B5%B7%E6%AD%A5-%E5%AE%89%E8%A3%85-Git

参考2:https://blog.csdn.net/jianjun_jiang/article/details/67061806

安装包依赖

[root@DB Downloads]# yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
[root@DB Downloads]# yum install asciidoc xmlto docbook2x

获取源码

[root@DB Downloads]# wget https://github.com/git/git/archive/v2.2.1.tar.gz
100%[======================================>] 5,145,893   32.9K/s   in 4m 8s   
2018-05-11 05:35:29 (20.2 KB/s) - “v2.2.1” saved [5145893/5145893]

[root@DB Downloads]# ls -l
-rw-r--r--. 1 root root 5145893 May 11 05:35 v2.2.1

保存的文件是:v2.2.1,直接解压会抛错,需要cp一份并加上后缀.tar.gz

[root@DB Downloads]# tar zxvf v2.2.1.tar.gz
tar (child): v2.2.1.tar.gz: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now

[root@DB Downloads]# cp v2.2.1 v2.2.1.tar.gz
[root@DB Downloads]# chmod 755 v2.2.1.tar.gz
[root@DB Downloads]# tar zxvf v2.2.1.tar.gz
[root@DB Downloads]# ls -l
drwxrwxr-x. 19 root root   12288 Dec 18  2014 git-2.2.1
-rw-r--r--.  1 root root 5145893 May 11 05:35 v2.2.1
-rwxr-xr-x.  1 root root 5145893 May 11 05:45 v2.2.1.tar.g

进入加压文件完成剩下安装步骤

[root@DB Downloads]# cd git-2.2.1
[root@DB Downloads]# make configure
[root@DB Downloads]# ./configure --prefix=/usr/local/git --with-iconv=/usr/local/libiconv
[root@DB Downloads]# make all doc
[root@DB Downloads]# make install install-doc install-html
[root@DB Downloads]# echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/bashrc
[root@DB Downloads]# source /etc/bashrc

最后检测版本是否有更新

[root@DB Downloads]# git --version
git version 2.2.1
### 回答1: 在Linux安装Git,可以按照以下步骤进行: 1. 打开终端,输入以下命令更新软件包列表: ``` sudo apt-get update ``` 2. 安装Git: ``` sudo apt-get install git ``` 3. 等待安装完成后,可以输入以下命令检查Git版本: ``` git --version ``` 如果输出了Git的版本信息,则说明安装成功。 4. 配置Git: 在安装完成后,需要进行一些基本的配置,包括设置用户名和邮箱等信息。可以使用以下命令进行配置: ``` git config --global user.name "Your Name" git config --global user.email "youremail@example.com" ``` 其,"Your Name"和"youremail@example.com"需要替换为自己的用户名和邮箱。 安装完成后,就可以在Linux使用Git进行版本控制了。 ### 回答2: Git是开源的分布式版本控制系统,它在Linux系统上应用广泛。在Linux安装Git非常简单,只需要以下几个步骤: 1. 检查系统是否已经安装Git。在终端输入git --version命令,如果系统已经安装Git则会显示当前Git的版本信息。如果没有安装,系统会提示“command not found”的错误信息。 2. 如果系统没有安装Git,则需要先安装Git。使用以下命令即可: sudo apt-get update sudo apt-get install git 3. 安装完成后,重新运行git --version命令,应该会显示系统已经安装Git版本信息。 4. 设置Git用户信息。使用以下命令设置Git用户的姓名和邮箱: git config --global user.name "Your Name" git config --global user.email "your_email@example.com" 这里需要注意的是,设置User Name和Email地址是为了在提交代码时Git需要进行身份标识和验证。 5. 如果需要在本地创建一个Git仓库,则需要进入工作目录并使用以下命令进行初始化: git init 6. 使用Git进行开发和管理代码。在Git进行操作的基本命令包括: git add:将文件加入到Git的版本控制git commit:将修改内容提交到Git的版本库git push:将本地的修改内容推送到远程Git服务器git pull:从远程Git仓库拉取最新的代码到本地仓库安装Git只需要几个简单的步骤,但是要熟练运用Git进行代码管理还需要多多练习和学习。 ### 回答3: 在Linux系统安装Git可以帮助我们进行代码版本控制,这里我们介绍如何在Linux系统安装Git。 首先,我们需要打开终端,输入以下命令更新系统: ```sudo apt update``` 接着,我们输入以下命令安装Git: ```sudo apt install git``` 执行完该命令后,Git就已经安装完毕了。 接下来,我们可以输入以下命令验证Git是否安装成功: ```git --version``` 如果终端输出类似于“git version 2.25.1”的信息,则说明Git安装成功了。 但是,如果你遇到了Linux系统没有预设的Git软件包或者是安装出现错误的问题,那么可以考虑通过源代码来安装Git,这里我们提供源码安装的流程: 1.我们可以在官网下载最新版本的Git源码:https://mirrors.edge.kernel.org/pub/software/scm/git/ 。 2.下载完成后,我们需要解压源码包,我们可以输入以下命令: ```tar -zxf git-2.25.1.tar.gz``` 3.接下来,我们进入解压后的目录,执行以下命令编译和安装: ``` cd git-2.25.1 make sudo make install ``` 执行完成后,就可以在Linux系统成功安装Git了。 总之,在Linux系统安装Git一般比较简单,用户可以根据自己的情况选择使用 apt命令 或源代码安装,学会了这个之后,我们的项目代码版本管理工作也会更方便。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值