Skip to main content
HomeTutorialsGit

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.

Topics

Git Courses

Course

Introduction to Git

4 hr
28.1K
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

The Complete Docker Certification (DCA) Guide for 2024

Unlock your potential in Docker and data science with our comprehensive guide. Explore Docker certifications, learning paths, and practical tips.

Matt Crabtree

8 min

Mastering API Design: Essential Strategies for Developing High-Performance APIs

Discover the art of API design in our comprehensive guide. Learn how to create APIs like Google Maps API with best practices in defining methods, data formats, and integrating security features.

Javeria Rahim

11 min

Data Science in Finance: Unlocking New Potentials in Financial Markets

Discover the role of data science in finance, shaping tomorrow's financial strategies. Gain insights into advanced analytics and investment trends.
 Shawn Plummer's photo

Shawn Plummer

9 min

5 Common Data Science Challenges and Effective Solutions

Emerging technologies are changing the data science world, bringing new data science challenges to businesses. Here are 5 data science challenges and solutions.
DataCamp Team's photo

DataCamp Team

8 min

A Data Science Roadmap for 2024

Do you want to start or grow in the field of data science? This data science roadmap helps you understand and get started in the data science landscape.
Mark Graus's photo

Mark Graus

10 min

Introduction to DynamoDB: Mastering NoSQL Database with Node.js | A Beginner's Tutorial

Learn to master DynamoDB with Node.js in this beginner's guide. Explore table creation, CRUD operations, and scalability in AWS's NoSQL database.
Gary Alway's photo

Gary Alway

11 min

See MoreSee More