Tutorial

How To Install Git on Debian 8

Published on June 30, 2015
How To Install Git on Debian 8
Not using Debian 8?Choose a different version or distribution.
Debian 8

Introduction

Git is a version control system distributed under the terms of the GNU General Public License v.2 since its release in 2005.

Git is software used primarily for version control which allows for non-linear development of projects, even ones with large amounts of data. Every working directory in Git is a full-fledged repository with complete history and tracking independent of network access or a central server.

The advantages of using Git stem from the way the program stores data. Unlike other version control systems, it is best to think of Git’s storage process as a set of snapshots of a mini filesystem, primarily on your local disk. Git maximizes efficiency and allows for powerful tools to be built on top of it.

In this tutorial we’ll install and configure Git on your Debian 8 Linux server.

Prerequisites

You’ll need the following items for this tutorial:

What the Red Means

The majority of code in this tutorial can be copy and pasted as-is! The lines that you will need to customize will be red in this tutorial.

Step 1 — Installing Git with APT

Before you install Git, make sure that your package lists are updated by executing the following command:

  1. sudo apt-get update

Install Git with apt-get in one command:

  1. sudo apt-get install git-core

This is the only command you’ll need to install Git. The next part is configuring Git.

Using apt-get is the easiest and probably one of the most reliable ways to install Git, because APT takes care of all the software dependencies your system might have.

Now, let us take a look at how to configure Git.

Step 2 — Configuring Git

Git implements version control using two primary settings:

  • A user name
  • The user’s email

This information will be embedded in every commit you make with Git so it can track who is making which commits.

We need to add these two settings in our Git configuration file. This can be done with the help of the git config utility. Here’s how:

Set your Git user name:

  1. git config --global user.name "Sammy Shark"

Set your Git email:

  1. git config --global user.email sammy@example.com

View all Git settings:

You can view these newly-configured settings (and all the previously existing ones, if any) using the --list parameter in the git config utility.

  1. git config --list

You should see your user settings:

Output
user.name=Sammy Shark user.email=sammy@example.com

.gitconfig

If you want to get your hands dirty with the Git configuration file, simply fire up nano (or your favorite text editor) and edit to your heart’s content:

  1. nano ~/.gitconfig

Here you can manually update your Git settings:

~/.gitconfig
[user]
        name = Sammy Shark
        email = sammy@example.com

This is the basic configuration you need to get up and running with Git.

Adding your username and email is not mandatory, but it is recommended. Otherwise, you’ll get a message like this when you use Git:

Output when Git user name and email are not set
[master 0d9d21d] initial project version Committer: root Your name and email address were configured automatically based on your username and hostname. Please check that they are accurate. You can suppress this message by setting them explicitly: git config --global user.name "Your Name" git config --global user.email you@example.com After doing this, you may fix the identity used for this commit with: git commit --amend --reset-author

Congratulations on your very own Git installation.

Conclusion

Here are a few tutorials which you can use to help you take full advantage of Git:

Happy branching!

Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

Learn more about our products

About the authors


Still looking for an answer?

Ask a questionSearch for more help

Was this helpful?
 
1 Comments


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Really nice introduction to this topic. What would be really nice is if we could have an overview of linking various repositories to our server, i.e., setting up keys etc

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Join the Tech Talk
Success! Thank you! Please check your email for further details.

Please complete your information!

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.