Tutorials
git
+1

# GIT SETUP: The Definitive Guide

In this tutorial, you'll learn how to set up Git on your computer in different operating systems.

Git is a free and open source tool which is primarily a distributed version control system. Git is a version control software that helps control the different versions of something. That might include a version of the source code. There is a lot of version control software such as Subversion, Bazaar, etc. Git, however, is the most popular and most used software to track the different versions of the code.

The main reason to use the version control system is that it lets you track the different and detailed version of the project. It also helps maintain the "collaboration" with the team. It becomes a problem solver mainly when the people who are working on the same project while on a common problem then that's where the version control system comes into play. It will help to know "who did the change", "why did someone do that change", "when did someone do that change", etc.

There are a lot of IDE's available for Python, and you also could integrate Git into your project. When choosing an IDE, you can go to this tutorial, Top 5 Python IDEs for Data Science. For full setup, there is also a brief tutorial on Datacamp Top 5 IDES.

3. You can install Git by selecting all the default and recommended options.

Once you do all of the above things, you can run git on the command line. It will then display different information including usage and common Git commands used in different situations.

There are different configuration levels in the Git. Configuration can be at three different levels. They are:

1. System
2. Global
3. Repository

There is a concept that there is level in between those three levels mentioned at the top. So, the highest level is System. Global is kind of the second highest and Repository is the lowest level among all of them. Also, the parameter can be set up in many levels, and if the same parameter for example, i.e., user.email is set at the Repository level then it will hide one specified in the Global level. If the same parameter is set in the Global level, it hides one specified in the System level.

Git has a command called config which can accept the parameter and also it can accept the argument to specify which configuration levels to specify on.

1. System level(--system) System-level covers an entire user, entire machine and all repos. On Windows, the config file will remain in the C:\Documents\Git\etc\gitconfig. While editing at this level, the changes can be seen all over the places, i.e., every repo level can be affected. So, editing the configuration level in the system is often discouraged.

2. Global level(--global) Global level configuration is the level where editing in this level effect at the user level. In specific, the users name applied to the one who is the operating system user. On Windows it is stored in C:\Users\<UserName>\.gitconfig.

3. Repository level(--local)

Repository level is the level which is specific to the repository. For example, if you have cloned any project from GitHub then by default git config will write on the local level when no configuration is passed. Also, there is a config file called as .git repository subfolder.In windows, it is located in C:\<RepoFolder>\.git\config.

## Basic Configuration

You can configure all of the steps shown below in the command line and get an enhanced experience.

##### You also can ensure the git's version

git --version

##### You can set up Git with your name

git config --global user.name "<Your-Full-Name>"

##### You can set up Git with your email

git config --global user.email "<your-email-address>"

##### You can make sure that Git output is colored

git config --global color.ui auto

##### You can display the original state in a conflict

git config --global merge.conflictstyle diff3

##### You can see current configurations type

git config --list

## Git with a code Editor:

You can use Git with the editors(IDE) you like. There are many popular code editors out there. You can use different editors according to your choice and to do that you can use google to search for how to do so?

Sublime Text Setup:

git config --global core.editor "'C:/Program Files/Sublime Text 2/sublime_text.exe' -n -w"

VSCode Setup:

git config --global core.editor "code --wait"

Atom Editor Setup:

git config --global core.editor "atom --wait"

3. You can install Git by selecting all the default and recommended options.

Once you do all of the above things, you can run git on the terminal. It then displays different information including usage and common Git commands used in different situations.

There are different configuration levels in Git. Configuration can be at three different levels. They are:

1. System
2. Global
3. Repository

There is a concept that there is level in between those three level mentioned at the top. So, the highest level is System and Global is kind of the second highest and Repository is the lowest level among all of them. Also, the parameter can be set up in many levels, and if the same parameter for example, i.e., user.email is set at the Repository level then it will hide one specified in the Global level, and if the same parameter is set in the Global level, it hides one specified in the System level.

Git has a command called config which can accept the parameter and also it can accept the argument to specify which configuration levels to specify on.

1. System level(--system) System-level covers an entire user, entire machine and all repos.On Linux, the config file will remain in the /etc/gitconfig. In macOS, there is a file called as /usr/local/git/etc/gitconfig. While editing in this level, the changes can be seen all over the place, i.e., every repo level can be affected. So, editing the configuration level in the system is often discouraged. Also, it requires an administrative privilege which is root in both macOS and Linux.

2. Global level(--global) Global level configuration is where editing in this level effects the user level. In specific, the users name applied to the one who is the operating system user. On both Linux and macOS it is stored in ~/.gitconfig.

3. Repository level(--local)

Repository level is the level which is specific to the repository. For example, if you have cloned any project from GitHub then by default, git config will write on the local level when no configuration is passed. Also, there is a config file called .git repository subfolder. In both Linux and macOS it is stored in ~/<MyRepoFolder>/.git/config.

## Basic Configuration

You can configure all of the steps shown below in the terminal to get the enhanced experience.

##### You can set up Git with your name

git config --global user.name "<Your-Full-Name>"

##### You can set up Git with your email

git config --global user.email "<your-email-address>"

##### You can make sure that Git output is colored

git config --global color.ui auto

##### You can display the original state in a conflict

git config --global merge.conflictstyle diff3

##### You can see current configuration type

git config --list

## Git with a code Editor

Sublime Text Setup

git config --global core.editor "'/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl' -n -w"

VSCode Setup

git config --global core.editor "code --wait"

Atom Editor Setup

git config --global core.editor "atom --wait"

## Conclusion

In this tutorial, you have learned the steps for the installation of Git in various operating systems. You have also learned about the basic configuration needed to set up with your favorite IDE's, and also you learned about the different configuration levels in Git.

There are many resources that you can learn the Git:

If you would like to learn more about Git, take DataCamp's Introduction to Git For Data Science course.