If you want to write code, Git is the first thing you want to install on your PC. But, how to do it? In this post, we will see how to install git and start using it in just a few minutes.
What is Git, and Do I need It?
If you are here, you probably just want to install git. Hence, you should know what it does and why do you need it. Nonetheless, if you don’t here’s a quick definition.
Git is a versioning system for the code you write.
This sounds good already, but Git is more than just that. If you are a newcomer to Git, you will enjoy reading What Is Git and How Developers Use it? I promise you, those are 10 minutes well-spent.
But now, it is time to see how to install git!
How to Install Git
Git works pretty much on any platform, from Window to Linux on a Raspberry Pi. Of course, the way we install it changes from platform to platform. Just scroll down and check how to do that on yours.
How to Install Git on Windows
Installing git on Windows is easy. You just have to download an executable installer, run it, and then you are ready to go. To download the installer, simply check the official Git website for Windows.
Once you went through this next-next installer, you will have two good things on your computer, the git CLI command and the git bash.
If you open the command prompt (the good old CMD), you can type git
. This will show you the help of the command, all the possible options you can use to play with git. Most notably, if you want to initialize a folder to be managed with git, you can simply use the command git init
.
The git bash is a sort of fake Linux terminal that comes with git in it. And, you can run it on Windows. Just search for the git bash in your start menu.
While the git bash can be useful, most of the time you will just need the CLI command.
With that, you have installed git on Windows, but your work doesn’t end here. In fact, if you work with online repositories, you will need to configure some authentication. You don’t want anyone to read or modify your code, after all, don’t you? Well, Git is a little bit lacking in the features you need there. Fortunately, we can fix it with the Windows Credential Manager. Just read about it after Linux and Mac OS sections (or click here).
How to Install Git on Linux
Git on Linux is like any other package, you install it through the package manager. Now, how to install it depends on your Linux distribution, but probably you already know that.
If you are on Debian-based distributions, like Ubuntu, go with this command in the terminal.
apt-get install git
Or, in case you are interested, add this PPA to obtain the latest stable version. Just know that the previous command will work just fine for most uses.
add-apt-repository ppa:git-core/ppa
apt-get update
apt-get install git
If you are on Fedora distributions like RedHat or CentOS, just use:
dnf install git
Note that if you are running on Fedora 21 or lower, you won’t have the dnf
command, but you will have yum
instead.
Not on Debian or Fedora? No worries, you can check the Git documentation at this page to see the installation on other distributions.
How to Install Git on Mac OS
If you are an Apple user, Git can work on Mac as well. The setup here is similar to the one on Windows, you just have to download a “next-next” installer, and run it. You can download the Git installer for MAC OS here.
Once done, you will have in your terminal the “git” command. And, just like on Windows or Linux, if you type “git” in the terminal you will see the help. While you can do many beautiful things with git, the first one you need to do is configure a folder to use git. When you want to do that, just navigate to the folder you want (in the terminal) and type git init
.
Enhance your Git Experience
Git Windows Credential Manager
While git works charmingly on its own, there are things it just can’t do. Most notably, you can have some problems authenticating different projects to different servers. That’s where the Git credential manager for windows comes in and solves our problems.
The Git Credential Manager is an open-source project, just like git. Thus, you can find it on GitHub at microsoft/Git-Credential-Manager-for-Windows. However, you don’t need to check that. You just need to install it.
How to install the Git Credential Manager for Windows? First, go to the official download page and download the executable file (.exe). Just to give you an idea, this one circled in red in the following screenshot is the executable file.
Just like with git, run the “next-next” setup, and you are done. As simple as that. All default settings will work fine. Of course, note that in the screenshot we have v1.20 because that was the latest at the time of writing this post. But don’t worry, the link will automatically update to the latest version as soon as it is out.
How to install GitHub Desktop
GitHub desktop makes all your working with git more beautiful. It is a simple application with a nice graphical interface that interacts with the git on your behalf.
So, to run the GitHub desktop app, you need to have installed git first. If you installed it, you are set to go. It will automatically find it and integrate with it. I love using GitHub desktop because it offers a simple interface to check your git changes and find differences between files. Many tutorials will use the GitHub desktop app, so I suggest downloading it.
To download the GitHub Desktop client, check the official download page. This is also available on Windows, Linux, and Mac OS. You have a simple “next-next” setup also in this case.
Git Embedded in Your Editor
Programmers normally don’t write code in the notepad. They use rich applications, the IDEs. Most IDEs natively integrate with Git, so that you can use Git directly in the place where you write code.
For example, Microsoft Visual Studio Code offers a git tab from its left menu.
Microsoft VS Code is free and supports tons of languages. Yet, other editors out there are just fine, and they provide a similar git integration. You just have to find one that fits in your workflow.
Wrap-up
In conclusion, I hope if you were wondering how to install git you have now a clear picture. As we saw, installing git is extremely easy on any platform. As a bonus, we saw two good tools that can help us be more productive with git, the Git credential manager for Windows and the GitHub desktop app.
I recommend downloading everything so that you can start working as a true developer!