Now that you know that Git is widely used for controlling version changes, it is time to learn how to install Git and start using it. Just like many other products for developers out there, Git is an open source and a free to use the system; therefore, it does not require complex actions to install it.
How you install Git depends on what operating system you have: Windows, Mac OS or Linux. The guidelines for each of the operating system differ a little bit, so you should always follow the guidelines for your system. You can install Git either manually or by using a package manager which automates some processes. In any case, installing Git shouldn't take long and is easy to complete.
Even though you already have Git installed on your computer, it might also be a good idea to check which version you have. Git is constantly updated, and new features are added or the bugs fixed. Therefore, it is a good idea to download the latest Git version and updated your Git.
In this tutorial, you will be guided through the installation process for each of the operating systems and shown several most common options to do it.
So start reading below!
How to Install Git: Main Tips
- There are many versions of Git available online for all the operating systems.
- There are several ways of how to install Git: you can install Git tools either through package managers, or other installers or source code compilation on the computer.
- After completing the installation, you always have to configure the information of a user - set a username and an email.
Git Install for Windows
There are a few ways of how to get Git on Windows:
- Using Git download file for Windows.
- Using a package manager for Windows.
- Choosing to install it together with your favorite Git GUI.
The first way is quite straightforward: you can get the official Git version for Windows at certain websites that provide the download files. You can get the latest release of Git for Windows here or here.
After downloading the installation file from one of the listed websites, you will have to continue Git installation by yourself. If you are not so sure how to do it (or let's be honest, don't have the time), you can also have it automated by enabling a package manager. Git Chocolaty is a good solution to use. Chocolaty is a package monitor for Windows run by the community.
Using automated installation is easy. After installing Chocolaty, just type this line into the command window
choco install git -params '"/GitAndUnixToolsOnPath"'.
Another way to get Git on your computer is by installing GitHub for Windows or any other Git GUI - Sourcetree, GitKraken, etc. Keep in mind, though that even if it is tempting, it is not the most recommended version. Software based on graphic user interface usually has its limitations. Learning how to operate a command line might be a more efficient option as it will be easier for you to switch between the systems.
More information on how to set up the system after the installation will be provided later.
Git Install for Mac OS
There are several ways of how you can install Git on Mac OS. The list of them looks like the following:
- Install the Xcode Command Line Tools.
- Use download file, a binary installer.
- Use a package manager.
The first way is one of the easiest. All you have to do is to install the Xcode Command Line Tools. If you already have it, newer versions of Mac OS may already have Git installed on your computer.
To check, type
$ git --version in the terminal. This command will show the version of Git you have on your machine:
$ git --version
git version 2.15.1
If you see that there is no Git on your Mac, you will be asked to run its installation. You can do this by running this command -
git in the terminal.
If you want a more up-to-date Git version, you can install it via installer from special download source pages. For that, you will need to download the installation files for Mac. You can do this by visiting Git website or other websites like SourceForge.
To start the installation with Homebrew type the following line to the terminal:
$ brew install git
If you want to use MacPorts, firstly search for the most recent Git ports and options available. You can do that by typing in the terminal the following lines:
$ port search git
$ port variants git
After that, type in the terminal:
$ sudo port install git +svn +doc +bash_completion +gitweb
Finally, to finish your Git installation you can use an alternative to command line as well - GUI (Graphic User Interface) app like GitHub for Mac. However, it is important to have in mind that Git commands remain the same across different platforms, while GUIs might differ depending on the platform.
Git Install for Linux
The easiest way to get Git on Linux is through the binary installer. You can do this by using the general package-management tools that come with your Linux distribution. You have to type specific commands in your shell in order to begin Git installation.
For Fedora use dnf / yum:
$ sudo dnf install git-all
If you are working on distribution based on Debian, for instance, Ubuntu, Git packages are available via apt:
$ sudo apt-get install git-all
You can find more options and instructions on Git installation for other Unix-like systems here.
You can check how successful the installation was by typing the following command into the shell:
$ git --version
There are many ways to use Git. First of all, there is a number of third-party tools available to download and use for Git. Even though Git comes with GUI, it is highly recommended not to rely exceptionally on it but nail the command line, too. After you have mastered the command line Git version, you will relatively easily figure out how to use the GUI version.
As its name suggests, it is a command line prompt interpreter. If you use or have used Windows, you probably have seen one. If you work with Windows and are accustomed to using CMD, you can use it for git commands.
Bash in Git is an emulation of a Unix shell for Linux and Mac OS, so you can use it on Windows if you are used to working with Linux.
It is a Graphical User Interface. This allows to use Git without touching Git Bash or CMD and avoid using command lines. However, built-in GUI has its limitations. On the one hand, it is very minimalistic. On the other hand, many GUI with different capabilities only can implicate a partial Git functionality. This why this tutorial focuses on using the command line.
How to Install Git: Summary
- A number of different versions exist online. They can be dowloaded and installed depending on what operating system - Windows, Mac OS or Linux - is used.
- How to install Git depends on the user preferences, operating sytem and knowledge: you can use different installers, such as package managers, source code or both.
- In order to start using Git, you will always have to set up user information, such as username and password.