Installing and configuring git in your system

Photo by Tekton on Unsplash

Installing and configuring git in your system

In this article, we will be looking at how you can install git on your system. After installing git on the system, we can use it to version control the directories.

Installing git on a Linux

Installing git on a Linux is pretty straightforward. In the case of Debian-based linux which uses apt package manager, you can run the following command in the terminal.

$ sudo apt install git -y

While you might be using another Linux distro or package manager, you can use the respective package manager's installation command to install git package.

Installing git on a macOS

Installing git on a macOS is also straightforward. You can install git by running the following command.

$ brew install git

Installing git on a Windows

Installing git on Windows is a bit more tedious than on Linux/macOS if you go with the installer. You will have to download an installer from the Git downloads page. After downloading the preferred installer(standalone/portable). You will run the installer as administrator and go through the installer steps. You can pretty much Next your way out of the installer.

Another way to install git on Windows is with winget which is a Windows package manager for Windows 10 and Windows 11. You can run the following command in the command prompt to install git and go through the installer.

> winget install --id Git.Git -e --source winget

Configuring git after installation

After the installation has been completed, we can start configuring the git. Some of the basic setups include the name and email of the author. This information can be set up on the git repository level or on a global level (applicable for all the git repositories for that user). Later when the user commits some changes in the git repository, the information setup in the config will be recorded. You can also change the information later if you want. You can set up info with the following command.

$ git config --global "<Your name here>"
$ git config --global "<Your email here>"

If you want, you can also set the config on the repository level. You can run the above commands without --global flag and the config will be limited to the repository you are on.

$ git config "<Your name here>"
$ git config "<Your email here>"

The global configuration we provided is stored in a .gitconfig file in the home directory of the user in Linux/macOS or the user's folder in Windows. The local config is stored in the config file inside the .git directory.

In this article we installed git on our system and configured the git. In the next article, we will work with a local repository.