Install Git and start using it like a Pro (Meet Git #2)
How to install Git step by step
In the previous article¹, we were considering Git as a tool that can be successfully used in areas other than software development. If you missed that article, or you don’t know what Git is, I encourage you to check it out.
Today I’m going to show you how to install Git, as it might not be that obvious, especially if you’re doing it for the first time.
Get the installer
Visit the official website² and click on the appropriate link, depending on whether you are using Windows, Linux or Mac.
Install Git for Windows
On Windows, to get started with Git, you can:
- Install Git from a downloaded installer
- Use a portable version that doesn’t require installation
- Install Git by using
winget
, which is a command-line tool (this won’t be covered in this article, however)
The latter is especially useful when you have a Windows account with limited permissions, and you can’t install software on your own (a company laptop is a good example here).
Given you want to install Git, get the installer, run it, and follow the instructions on the screen. Essentially, keep default settings on most screens, with a few exceptions. I will cover these exceptions in next paragraphs.
Bash profile for Windows Terminal
On the screen with the selection of components, I would also recommend selecting “Add a Git Bash Profile to Windows Terminal”.
This option may be useful, if your Windows comes with Windows Terminal. If you don’t have it, you can install this tool from Microsoft Store, but this is completely up to you. Keep in mind that Git comes with its own command line, called Git Bash, so you’ll be able to use Git even if you omit this checkbox.
Besides that, you can create a profile within Windows Terminal for Git Bash manually at any time, so don’t worry too much about this setting.
Choosing the default text editor
The next setting worth considering is a text editor associated with Git. Using Git requires writing some text, and because Git is not a text editor itself, we have to choose our favorite tool. The default Git’s text editor, Vim, is quite powerful, but it can give you a headache if this is your first contact with this editor. I remember myself boxing with Vim, because it turned out that even such a simple operation as closing the application is challenging enough for newcomers.
If you’re not tech-savvy, or you don’t want to spend your time to learn another tool, select the text editor you are familiar with. I personally stick to Vim, but it’s just a matter of taste, and you can change your choice at any time.
Basically, you can control this setting by changing a property managed by Git, named core.editor
— I’ll show you how to change this and other settings in the next article, when we’ll be configuring Git for our first repository.
Configuring the line endings
Because Git is a tool that primarily operates on text files, Git wants to know how it is supposed to act on text files and their line endings.
If you’re installing Git on Windows, it’s most likely you want to keep the default setting “Checkout Windows-style, commit Unix-style line endings”.
Keep this setting as-is for now — I will explain the differences between these options in one of the next articles. This behavior can be configured at any time via the core.autocrlf
property.
Configuring extras
The settings below are completely optional, and they don’t affect your workflow, but it’s worth to select them for better overall performance.
On the “Configuring extra options” and “Configuring experimental options” screens, select
- “Enable file system caching” (the property stored in Git as
core.fscache
) - “Enable experimental built-in file system monitor” (the property stored as
core.fsmonitor
)
When you’ve finally gone through the wizard…
Click the “Finish” button, open “Start” menu, and search for “Git Bash”. If the installation was successful, you’ll see a command line as shown below.
Use Git Portable
Like I wrote earlier, if you don’t want to (or you can’t) install the standalone version of Git, you can go for Git Portable.
To do so, follow these simple steps:
- Get the file with Git Portable (as of October 5, 2022, there is a .7z archive to download)
- Extract the archive with a tool that supports .7z, like 7-zip³
- Run
git-bash.exe
from the extracted directory - Voilà!
Install Git on Linux
Installation of Git on Linux is a much more straightforward process compared to Git for Windows, but this has also some drawbacks, i.e. you need to do additional configuration yourself.
In the next article, I’m going to explain how to configure Git when you don’t have such a fancy wizard as Windows users have.
Git on Ubuntu
In order to install Git on Ubuntu, perform these two steps:
- Open terminal
- Type
git --version
, and if the message says something like “Command ‘git’ not found”, proceed to the next step - Type:
sudo apt install git
, and confirm by hittingy
on your keyboard
To verify that Git has been installed, type againgit --version
— if everything is fine, this time you should see the version of installed Git.
Git on Fedora
The installation process on Fedora is almost identical to the one on Ubuntu. The main difference is the package manager, i.e. Fedora comes with dnf
, whereas Ubuntu uses apt
.
Fedora is smart enough, so that when you type git --version
in the terminal, and Git is not installed, you’ll be asked to install a suggested package containing Git. This is very convenient, and you just have to confirm the installation by hitting y
on your keyboard.
Alternatively, you can type the full command, similarly as on Ubuntu: sudo dnf install git
Git on macOS
In general, there are several ways to install Git on Mac, and the easiest way is to download the installer from this website⁴. Then, run the installer and follow the instructions on the screen.
What’s next?
Congratulations! You’ve just installed Git on your machine, and you’re almost ready to use it.
Wait, almost? Well, we need to learn how to check the initial configuration, and how to make some adjustments in settings. Fortunately, I’ll teach you all of this in the next part, so stay tuned!
References
[1] Krystian Szpiczakowski, Program that will boost your productivity https://medium.com/@kszpiczakowski/program-that-will-boost-your-productivity-36f0f63935b1
[2] Git official website, https://git-scm.com/downloads
[3] 7-zip official website, https://7-zip.org/
[4] Git installer for Mac, https://sourceforge.net/projects/git-osx-installer/files/