Here’s the simple rule — you’re a developer means that you ABSOLUTELY have to have Git installed on your machine. In this post, we'll quickly look at how this can be done on your Linux, macOS and Windows machines.
The way we install Git on a Linux machine, or the way to do it rather, is dependent on the distribution you’re using, because of the tools that come packaged with them.
If you sue Fedora or any other distribution that is similar to it such as RHEL or CentOS, open Terminal and run the following command:
sudo dnf install git-all
If the distribution you’re using is a Debian based one, like Ubuntu, you can try running the following command in Terminal
sudo apt install git-all
In either case, the command will require you to enter your administrate password, after which the system will take care of the installation process. If you need information on installing Git in other Linux distros, or for more details regarding Git installation in Linux systems, check out this page.
Good news for developers using macOS is that if you’ve installed XCode and XCode command line tools, Git is probably installed in your system. You can verify this by running the following command in Terminal:
if you have a valid installation, you’ll see something like this:
git version 2.19.0
Apple maintains a fork of Git which it ships out. The problem here is that more often than not, Apple’s version is at least a couple of versions behind the original Git project. So let’s go ahead and look at methods to set up Git on macOS
- Download the free Git for Mac installer.
- Follow the on-screen instructions and complete the installation process.
That should do the trick. If you now re-run the ‘git -version’ command in the Terminal, you should get a version number.
If you have the most popular package manager for macOS a.k.a Homebrew installed, you can use it to install Git. Open Terminal and run the following command:
brew install git
Homebrew will now run the steps and scripts to install Git. If you now re-run the ‘git -version’ command in the Terminal, you should get a version number.
- Download the free Git for Windows installer.
- When you’ve successfully started the installer, you should see the Git Setup wizard screen. Follow the Next and Finish prompts to complete the installation. The default options are pretty sensible for most users.
If all went well, Git should be set up on your system now. Let’s verify this. Open a Command Prompt (or Git Bash if during installation you elected not to use Git from the Windows Command Prompt). Run the following command:
You should be able to see a version number now.
While the above list does not include ALL the ways to set up Git on your system, these are the most popular and tested ones and should be good for everybody