Even if it has already been installed, it is a good idea to update to the latest version.
Each of the systems has a different way to do this installation, and, by default, once performed, the Git commands are available through the command terminal or console. You can install it as a package or through another installer, or even download the source code and compile it.
Next you will see how to install the git on major operating systems and on different Linux distributions.
Install Git on Windows
There are a few ways to install Git on Windows. The most official version is available for download from the Git website.
Access the address https://git-scm.com/download/win and the download will start automatically. Note that this is a project called Git for Windows, which is separate from the main Git project itself; for more information about it, go to the page https://gitforwindows.org.
To download an automated installation, you can use the Git Chocolatey package. Watch that the Chocolatey package is maintained by the community. Even so, each version of each package goes through a rigorous moderation process before going live, which typically includes:
- Security, consistency and quality verification
- installation test
- Virus Scanning Using VirusTotal
- Moderated by humans who perform the final review and sign them
One more way to install Git on Windows is by installing the GitHub for Windows. The installer includes a command-line version of Git as well as the GUI.
It also works fine with PowerShell, and configures solid credential caching and proper CRLF settings.
In other articles/lessons I will deal with credentials and CRLV settings
You can download it from the GitHub for Windows page at https://windows.github.com.
Install Git on Mac
As with Windows, there are several ways to install Git on a Mac. The easiest is to install the Xcode command line tools.
On Mavericks (10.9) or above, you can do this by simply running the `git` command in the Terminal Console for the first time. If it is not installed, the system will ask you to install it.
If you want to work with the most up-to-date version, usually not available at the same speed in the repositories, you can install it using a binary installer.
An OSX Git installer is maintained and available for download from the Git website, go to http://git-scm.com/download/mac to download the installer.
You can also install it as part of the GitHub installer for Mac. Your GUI Git tool has an option to install command line tools.
To download this tool, go to the GitHub for Mac page at http://mac.github.com.
Install Git on Linux
The process of installing Git on Linux/Unix is usually done through the basic package management tool that comes with your distribution.
Since Git is an essential tool for developers and infrastructure professionals, DevOps, the packages for its installation are always present and well updated.
For Linux distributions that use the package manager
yum, like Linux Fedora for example, you can use the following command:
$ sudo yum install git-all
yum will work for Fedora up to version 21, for Fedora 22 and newer use
$ dnf install git
Debian, Ubuntu, Mint
If you use a Linux based Debian distribution like Ubuntu or Mint, use the package manager
$ sudo apt-get install git-all
You can use the following official repository for the latest versions, it should work for all three Debian based distributions:
$ add-apt-repository ppa:git-core/ppa $ apt update $ apt install git
$ emerge --ask --verbose dev-vcs/git
$ pacman -S git
$ zypper install git
$ urpmi git
$ nix-env -i git
$ pkg install git
Solaris 9/10/11 (OpenCSW)
$ pkgutil -i git
Solaris 11 Express
$ pkg install developer/versioning/git
$ pkg_add git
$ apk add git
Red Hat Enterprise Linux, Oracle Linux, CentOS, Scientific Linux, et al.
RHEL and derivatives typically provide older versions of git. You can download a tarball and compile from source or use a third-party repository such as IUS Community Project to get a newer version of git.
Simple as that, running the correct installation command for your distribution, Git will be available, to test you can check your version with the following command:
$ git --version
keep up to date