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 12, 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.

Topics

Git Courses

course

Introduction to Git

4 hr
37.2K
Familiarize yourself with Git for version control. Explore how to track, compare, modify, and revert files, as well as collaborate with colleagues using Git.
See DetailsRight Arrow
Start Course
See MoreRight Arrow
Related
Git

blog

What is Git? - The Complete Guide to Git

Learn about the most popular version control system and why it's a must-have collaboration tool for data scientists and programmers alike.
Summer Worsley's photo

Summer Worsley

14 min

tutorial

Git Install Tutorial

Learn about Git initial setup, Git LFS, and user-friendly Git GUI applications in this in-depth tutorial.
Abid Ali Awan's photo

Abid Ali Awan

9 min

tutorial

Python Setup: The Definitive Guide

In this tutorial, you'll learn how to set up your computer for Python development, and explain the basics for having the best application lifecycle.

J. Andrés Pizarro

15 min

tutorial

GitHub and Git Tutorial for Beginners

A beginner's tutorial demonstrating how Git version control works and why it is crucial for data science projects.
Abid Ali Awan's photo

Abid Ali Awan

17 min

tutorial

Setup a Data Science Environment on your Computer

Learn about the various options you have to setup a data science environment with Python, R, Git, and Unix Shell on your local computer.
DataCamp Team's photo

DataCamp Team

8 min

tutorial

Git Reset and Revert Tutorial for Beginners

Discover how to use Git reset and revert to manage your project history. Practice with detailed examples using soft, mixed, and hard resets. Learn the difference between Git reset and revert.
Zoumana Keita 's photo

Zoumana Keita

10 min

See MoreSee More