Git is an immensely popular distributed version control system that helps users in managing all kinds of projects efficiently. More specifically, Git enables tracking of code changes, creating different code branches, and collaborating with a team of developers along with providing many more features. In fact, Git also hosts one of the most popular open-source projects, Linux Kernel.
If you are also interested in hosting your projects on Git repositories but have no idea how to install Git on your system, then you are at the right place. This guide is going to explain how to install Git on CentOS, Ubuntu, and Windows systems in a detailed manner.
Git Installation on CentOS 6.x/7.x
For installing Git on CentOS release version 6.x/7.x, you can use the ‘yum’ package manager. You need to run the following command to install Git:
$ sudo yum install Git
You may see a prompt on your screen to confirm the installation, you need to confirm by pressing ‘y’:
Is this ok [y/d/N]: y
Here is the end of the installation snippet of Git on CentOS 7 minimal setup that you will see on your system screen. This confirms that Git is installed on your CentOS 7, and please note that the dependencies installed along with Git can vary depending upon your OS version and installed packages.
git.x86_64 0:188.8.131.52-23.el7_8 Dependency Installed: perl.x86_64 4:5.16.3-297.el7 perl-Carp.noarch 0:1.26-244.el7 perl-Encode.x86_64 0:2.51-7.el7 perl-Error.noarch 1:0.17020-2.el7 perl-Exporter.noarch 0:5.68-3.el7 perl-File-Path.noarch 0:2.09-2.el7 perl-File-Temp.noarch 0:0.23.01-3.el7 perl-Filter.x86_64 0:1.49-3.el7 perl-Getopt-Long.noarch 0:2.40-3.el7 perl-Git.noarch 0:184.108.40.206-23.el7_8 perl-HTTP-Tiny.noarch 0:0.033-3.el7 perl-PathTools.x86_64 0:3.40-5.el7 perl-Pod-Escapes.noarch 1:1.04-297.el7 perl-Pod-Perldoc.noarch 0:3.20-4.el7 perl-Pod-Simple.noarch 1:3.28-4.el7 perl-Pod-Usage.noarch 0:1.63-3.el7 perl-Scalar-List-Utils.x86_64 0:1.27-248.el7 perl-Socket.x86_64 0:2.010-5.el7 perl-Storable.x86_64 0:2.45-3.el7 perl-TermReadKey.x86_64 0:2.30-20.el7 perl-Text-ParseWords.noarch 0:3.29-4.el7 perl-Time-HiRes.x86_64 4:1.9725-3.el7 perl-Time-Local.noarch 0:1.2300-2.el7 perl-constant.noarch 0:1.27-2.el7 perl-libs.x86_64 4:5.16.3-297.el7 perl-macros.x86_64 4:5.16.3-297.el7 perl-parent.noarch 1:0.225-244.el7 perl-podlators.noarch 0:2.5.1-3.el7 perl-threads.x86_64 0:1.87-4.el7 perl-threads-shared.x86_64 0:1.43-6.el7 rsync.x86_64 0:3.1.2-10.el7 Complete! $
Git Installation on CentOS 8.x
If you wish to install Git on CentOS version release 8.x or RHEL 8.x, you can use the DNF package manager. Install Git by running the following command:
$ sudo dnf install git
Now you may be prompted to confirm the installation. You will have to type ‘y’ and hit enter:
Is this ok [y/N]: y
This is the installation snippet that you will come across upon completion of the installation of Git on CentOS 8:
$ sudo dnf install git CentOS-8 - AppStream 9.1 kB/s | 4.3 kB 00:00 CentOS-8 - AppStream 752 kB/s | 6.2 MB 00:08 CentOS-8 - Base 6.5 kB/s | 3.9 kB 00:00 CentOS-8 - Base 1.6 MB/s | 2.3 MB 00:01 CentOS-8 - Extras 3.5 kB/s | 1.5 kB 00:00 CentOS-8 - Extras 12 kB/s | 8.1 kB 00:00 Extra Packages for Enterprise Linux Modular 8 - x86_64 15 kB/s | 8.5 kB 00:00 Extra Packages for Enterprise Linux 8 - x86_64 10 kB/s | 9.1 kB 00:00 Extra Packages for Enterprise Linux 8 - x86_64 2.4 MB/s | 8.6 MB 00:03 Dependencies resolved. ========================================================================================================================================================================== Package Architecture Version Repository Size ========================================================================================================================================================================== Installing: git x86_64 2.27.0-1.el8 AppStream 164 k Installing dependencies: git-core x86_64 2.27.0-1.el8 AppStream 5.7 M git-core-doc noarch 2.27.0-1.el8 AppStream 2.5 M perl-Error noarch 1:0.17025-2.el8 AppStream 46 k perl-Git noarch 2.27.0-1.el8 AppStream 77 k Transaction Summary ========================================================================================================================================================================== Install 5 Packages Total download size: 8.5 M Installed size: 45 M Is this ok [y/N]: y Downloading Packages: (1/5): git-2.27.0-1.el8.x86_64.rpm 299 kB/s | 164 kB 00:00 (2/5): perl-Error-0.17025-2.el8.noarch.rpm 173 kB/s | 46 kB 00:00 (3/5): perl-Git-2.27.0-1.el8.noarch.rpm 182 kB/s | 77 kB 00:00 (4/5): git-core-doc-2.27.0-1.el8.noarch.rpm 813 kB/s | 2.5 MB 00:03 (5/5): git-core-2.27.0-1.el8.x86_64.rpm 431 kB/s | 5.7 MB 00:13 -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Total 615 kB/s | 8.5 MB 00:14 Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Installing : git-core-2.27.0-1.el8.x86_64 1/5 Installing : git-core-doc-2.27.0-1.el8.noarch 2/5 Installing : perl-Error-1:0.17025-2.el8.noarch 3/5 Installing : perl-Git-2.27.0-1.el8.noarch 4/5 Installing : git-2.27.0-1.el8.x86_64 5/5 Running scriptlet: git-2.27.0-1.el8.x86_64 5/5 Verifying : git-2.27.0-1.el8.x86_64 1/5 Verifying : git-core-2.27.0-1.el8.x86_64 2/5 Verifying : git-core-doc-2.27.0-1.el8.noarch 3/5 Verifying : perl-Error-1:0.17025-2.el8.noarch 4/5 Verifying : perl-Git-2.27.0-1.el8.noarch 5/5 Installed products updated.
Git Installation on Ubuntu
The easiest way to install Git on Ubuntu is by using an apt package manager. First of all, you need to update the apt package index by running the following command in the terminal:
$ sudo apt update
The terminal will show the following output:
Hit:1 http://in.archive.ubuntu.com/ubuntu groovy InRelease Hit:2 http://in.archive.ubuntu.com/ubuntu groovy-updates InRelease Hit:3 http://in.archive.ubuntu.com/ubuntu groovy-backports InRelease Get:4 http://security.ubuntu.com/ubuntu groovy-security InRelease [110 kB] Fetched 110 kB in 1s (110 kB/s) Reading package lists... Done Building dependency tree Reading state information... Done
All packages are up to date.
Then you will be required to use the following command for the installation of Git on your Ubuntu system:
$ sudo apt install git
You may see a prompt to confirm, which you can do by entering ‘Y’:
Do you want to continue? [Y/n] Y
Then you will see this installation snippet for Git installation on Ubuntu 20:
$ sudo apt install git Reading package lists... Done Building dependency tree Reading state information... Done
The following additional packages will be installed:
git-daemon-run | git-daemon-sysvinit git-doc git-el git-email git-gui gitk gitweb git-cvs git-mediawiki git-svn
The following NEW packages will be installed:
git git-man liberror-perl
0 upgraded, three newly installed, 0 to remove, and 0 not upgraded.
Need to get 5,764 kB of archives.
After this operation, 41.2 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y (Type Y and Hit Enter)
Get:1 http://in.archive.ubuntu.com/ubuntu groovy/main amd64 liberror-perl all 0.17029-1 [26.5 kB]
Git Installation on Windows
Git can be installed on Windows by downloading the applicable Windows binary installer, available on the official Git website.
On the official Git website, you will find 32-bit and 64-bit versions of Git, and you can download either of them depending on the architecture of your system. Generally, new systems support 64-bit architecture, and thus, the default downloader on the Git website should be apt for most users.
Follow the steps below to proceed with the installation process:
- After you have downloaded the Git installer, you need to launch it. You will see the installation wizard on your system screen. On this installation wizard, you need to accept all the prompts that you may see in Windows’ User Access Control at the start of the installation. It will then ask for administrative access, which you need to accept so that the installation can be initiated.
- If due to any administrative issues, the installation is unable to process, there is an alternative available. You can use the portable version of Git in this case. Whatever version of Git you are installing, you will need to accept the License Agreement and then click on the ‘Next’ option at the bottom of the window.
- Now you are required to choose the installation path for Git, or you can also leave it to be the default path that is displayed on the dialog box. After specifying the desired installation path, you can click on the ‘Next’ button.
- You will now come across a ‘Select Components’ dialog box on which you can choose the Git components that you need to install. You can leave this as default as all the essential components that you need are already selected. After selecting the required components, click on the ‘Next’ button.
- After seeing the Start Menu shortcut options, click Next.
- You will be asked to choose the default editor that will be used by Git. You can select one among the available options, such as Notepad, in the drop-down list. After choosing the default editor, click Next to continue.
- Then you will see the dialog box for naming the initial branch for the new repositories. You can leave it as it is and “Let Git decide,” or you can name it yourself in the second option and when done, click on the ‘Next’ button.
- By default, Git will be added to the Windows PATH variable to be accessible for other programs like Command Prompt, etc., and you can choose the 1st option if you would like to use Git from Git Bash only. Once you have selected your desired option, click the ‘Next’ button to continue.
- Network-related actions for Git like push and pull requests require Secure Shell or SSH executable, and on this dialog box, you are given a choice to select the SSH executable you prefer. The default option selected is “Use OpenSSH,” and it should be left as it is except if you specifically need TortoisePlink. To continue with the installation, click the ‘Next’ button.
- You can choose the default selected option for choosing the HTTPS transport backend, “Use the OpenSSL library”. The other option is the one that comes with Windows; you can choose whichever you want and then click on Next.
- You need to confirm the commit style next. It should be noted that Windows and Linux/Unix systems interpret end-of-line differently. So, for making the code compatible between different development platforms, Git must be made aware of how the code file has an end-of-line character specified and whether it is required to be switched to another style. The default option selected here is ideal as it enables all the switching and conversion to happen in the background by Git, and if you are unsure what option you would like to choose, then you can consult your Git code administrator. When done, click on the ‘Next’ button to continue further.
- The next dialog box that you see will ask you to configure the terminal emulator, which enables you to either have a BASH-like environment or Windows Command Prompt as the default console. You can choose either of these options as they both work nicely, and after selecting one of them, you can click Next.
- Now you will be asked to specify the default “git bull” behavior, and in this case, you should go with the default option selected unless you have certain specifications. When selected, click on the ‘Next’ button to move on.
- The credential manager is designed to store your private information, such as your passwords and keys that you require for logging in to various remote Git repositories. The first option should also be selected, which is the default because Git Credential Manager has been deprecated. You need to click on the ‘Next’ button to continue.
- Now you will be required to select some additional options such as file system caching and symbolic links. You can click on Next after selecting the desired options.
- The experimental configuration dialog box is meant for you to enable features on Git that have not been fully developed and tested yet. You can leave the options unchecked except if you need any of those. At last, click on the ‘Install button at the bottom of the dialog box so that the installation process can begin with your preferred selections.
- Now you will observe that the installation of Git on your Windows system begins, and you have to wait for it to be completed.
- After the installation is complete, a final dialog will appear that will enable you to launch Git Bash.
- In the future, you can launch Git Bash or Git GUI by clicking on its icon in your Windows Start Menu. Git Bash is a similar command line (CLI) that Linux offers, and all Git commands are supported by it. Now, you can verify the Git version by launching the Git Bash and following the steps mentioned in the next section.
In order to verify your Git installation and check if its the right version that you have installed, you need the run the following command on the Git Bash in Windows:
$ Git --version
git version 2.27.0 $
The purpose of this guide is to define the individual steps required to install Git on different operating systems, namely CentOS, Ubuntu, and Windows. If you follow the steps mentioned within the article properly, you will be able to install Git with ease. If you have any issues with installing Git or using Git, you can check out the resources available on their official website.