DevOps tool chain (2) - the latest version of git for CentOS 7.4 source installation

Posted by rochakchauhan on Sat, 04 Apr 2020 07:20:18 +0200

Software versions:
Operating system: CentOS 7.4
Git: 2.17.0
System user: root

1. Installation environment

# Install gcc
[root@localhost bin]# yum install gcc

# Install gcc-c + + (not sure if it is not necessary)
[root@localhost bin]# yum install gcc-c++

# Install packages required for compilation (not sure if not required)
[root@localhost bin]# yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
[root@localhost bin]# yum install gcc perl-ExtUtils-MakeMaker

2. Download git source code

The latest download page of git source code: Download address of git source code
2.17.0 latest download address: git 2.17.0 source download address

3. Decompress git source compression package

It can be downloaded by thunderbolt or by wget.
wget -P /home/zhangsan/git-2.17.0
I download it through thunderbolt, and then send it to the server through sftp. . enter the directory where the compressed package is located

[root@localhost ~]# tar -zxvf git-2.17.0.tar.gz
[root@localhost ~]# cd git-2.17.0
[root@localhost git-2.17.0]# ./configure --prefix=/opt/git-2.17.0
[root@localhost git-2.17.0]# make
[root@localhost git-2.17.0]# make install

4. add bin

# First, check whether git can be executed
[root@localhost ~]# git --version

## If the version number of git is not returned, or the version number returned is incorrect
[root@localhost ~]# cd /usr/bin
# I installed a 1.8.x version with yum before. Although I remove d it, the old version is still displayed
[root@localhost bin]# mv git git.back

# Make a new one
[root@localhost bin]# ln -s /opt/git-2.17.0/bin/git git
[root@localhost bin]# git --version
git version 2.17.0  ## Normal.

5. configure git

# Configure git Global
git config --global "zhangsan"
git config --global ""

# Generating key
ssh-keygen -t rsa -C ""
Enter file in which to save the key (/root/.ssh/id_rsa):  # The location where the key is stored after generation / root/.ssh
# After knocking back
Enter passphrase (empty for no passphrase):  # If you enter a password in this place, you need to enter a password when using git. If you leave it blank, you can leave the password blank
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/
The key fingerprint is:
# A large number of them appear below, indicating that the generation is complete.

6. configure ssh

On the gitlab server, log in with the user name. Click the icon in the upper right corner, and click settings in the drop-down menu.
On the left SSH KEYS, add the newly generated public key

Topics: git ssh yum CentOS