Git is the most popular distributed version control system. It helps to track changes in source code during software development. It allows to collaborate with programmers, revert to previous changes and create branches. This tutorial will describe how to install Git on CentOS 7 system.
You must have logged in with non-root user account with sudo privileges.
Install Git on CentOS 7
You should enable Git repository to install latest Git on your CentOS system. At first, you need to create YUM repository configuration file in /etc/yum.repos.d/ directory with name wandisco-git.repo. Run the below command to do it:
sudo nano /etc/yum.repos.d/wandisco-git.repo
Add the following lines to file:
[wandisco-git] name=Wandisco GIT Repository baseurl=http://opensource.wandisco.com/centos/7/git/$basearch/ enabled=1 gpgcheck=1 gpgkey=http://opensource.wandisco.com/RPM-GPG-KEY-WANdisco
Save and exit using CTRL+X then typing ‘Y’.
Next, Import GPG key for added repository key typing below command.
sudo rpm --import http://opensource.wandisco.com/RPM-GPG-KEY-WANdisco
Now you can install Git by executing below command:
sudo apt install git
Once the installation is finished you can verify by typing:
It will show output like below:
Output git version 2.18.0
That’s all. You have successfully installed Git version on you CentOS 7 system.
Setting Up Git
Now your Git is installed and you need to configure it by setting up email address and username:
git config --global user.name "Your Name" git config --global user.email "youremail@ yourdomain.com"
You can see entered details by typing:
git config --list
These settings are stored at
~/.gitconfig file and you can see content as below:
[user] name = Your Name email = email@example.com
You can make other git configuration changes by using
git config command or you can edit the
~/.gitconfig file manually.
Finally, you have learned how to install Git on your CentOS server and how to Setting up Git. You can learn more about Git at Pro Git Book.
If you face any problem at installation time, leave a comment below.