Skip to main content

GIT SETUP: The Definitive Guide

In this tutorial, you'll learn how to set up Git on your computer in different operating systems.
Dec 2018  · 7 min read

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.

For Downloading Git in Windows:

  1. You can get to Git's website Git Download
  2. Download the Software according to the Windows version.
  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

For more information, you can visit this site: Git Configuration.

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"

For downloading Git in Mac/Linux Setup:

  1. You can get to Git's website Git Download
  2. Download the Software according to the Mac/Linux version.
  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:

 1. Getting Git Right

 2. Git Basics

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

Introduction to Git

Beginner
4 hours
125,217
This course is an introduction to version control with Git for data scientists.
See DetailsRight Arrow
Start Course
See all coursesRight Arrow
Related
Data Science Concept Vector Image

How to Become a Data Scientist in 8 Steps

Find out everything you need to know about becoming a data scientist, and find out whether it’s the right career for you!

Jose Jorge Rodriguez Salgado

12 min

YOLO Object Detection Explained

Understand YOLO object detection, its benefits, how it has evolved over the last couple of years and some real-life applications.
Zoumana Keita 's photo

Zoumana Keita

5 Ways to Use Data Science in Marketing

Discover five ways you can use data science in marketing. Get ahead of the game, improve your data skills, and work on a data science marketing project.
Natassha Selvaraj's photo

Natassha Selvaraj

DC Data in Soccer Infographic.png

How Data Science is Changing Soccer

With the Fifa 2022 World Cup upon us, learn about the most widely used data science use-cases in soccer.
Richie Cotton's photo

Richie Cotton

_Quote.png

The Deep Learning Revolution in Space Science

Justin Fletcher joins the show to talk about how the US Space Force is using deep learning with telescope data to monitor satellites, potentially lethal space debris, and identify and prevent catastrophic collisions. 

Richie Cotton's photo

Richie Cotton

53 min

Regular Expressions Cheat Sheet

Regular expressions (regex or regexp) are a pattern of characters that describe an amount of text. Regular expressions are one of the most widely used tools in natural language processing and allow you to supercharge common text data manipulation tasks. Use this cheat sheet as a handy reminder when working with regular expressions.
DataCamp Team's photo

DataCamp Team

See MoreSee More