W3docs

Introduction

Read descriptions about version control systems, source code management, version control software, what is Git, install Git, SHH Keys, and Git repository.

Version Control Systems

This is the starting point of the Learn Git course. By the end of this introduction you will understand what a version control system is, why teams rely on one, how Git differs from older tools, and how to get Git running on your machine. Each section below links to a full chapter where the topic is explained in depth.

Here is the path this section covers:

Version Control System

A Version Control System (VCS) is a tool that records changes to a set of files over time so you can recall any earlier version, see who changed what, and work in parallel without overwriting each other. It is sometimes called Source Code Management (SCM) or Revision Control System (RCS).

There are three families of VCS, and they differ in where the history lives:

  • Local VCS keep every version in a database on a single computer (for example, the old rcs tool). Simple, but a disk failure loses everything and there is no real collaboration.
  • Centralized VCS (CVCS) such as Subversion (SVN) or CVS store the full history on one central server. Developers check out a working copy, but the history exists only on the server. If the server is down, nobody can commit; if it is lost without a backup, the project history is gone.
  • Distributed VCS (DVCS) such as Git or Mercurial give every developer a complete copy of the repository, including its entire history. You can commit, branch, and view the log while completely offline, and any clone can restore the others.

Git is a distributed VCS, which is the main reason it is fast and resilient.

Source Code Management

Source code management (SCM) is essentially another name for version control. It is the practice (and the tooling) of tracking modifications to a source code repository so that you can review history, compare revisions, and resolve merge conflicts — the situation where two people change the same lines and the tool needs a human to decide which change wins.

SCM lets each developer work independently on a separate branch and later combine the work with a merge. Beyond raw history, good SCM provides blame/annotation, tagging of releases, and the ability to revert a bad change in seconds.

Version Control Software

Version control software is the concrete program that implements version control for your team. For a single developer it is convenient; for a team with multiple developers it is a necessity, because it is the only safe way to merge everyone's work.

Popular options include Git, Subversion (SVN), CVS, Mercurial, and Monotone. Each project picks the one that fits its workflow; Git is by far the most common today. The following chapters compare their pros and cons in detail.

What is Git

Git is the distributed version control system used across most of the software world. It tracks changes to your source code during development and handles projects of any size, from a one-file script to the Linux kernel.

Git stands out for a few reasons:

  • Cheap, fast local branching — creating a branch is nearly instant because it is just a pointer to a commit.
  • A staging area — you choose exactly which changes go into the next commit with git add before running git commit.
  • Works offline — every operation except syncing with a remote runs against your local copy.
  • Data integrity — every commit is identified by a SHA-1 hash of its contents, so corruption is detectable.

Install Git

Working with Git starts with installing it (or updating your existing copy). The installer differs by operating system:

  • macOS — the Git for Mac installer, Homebrew (brew install git), or MacPorts.
  • Windows — the official Git for Windows package, which includes Git Bash.
  • Linux — your distribution's package manager, e.g. sudo apt install git on Debian/Ubuntu.

Once installed, confirm the version from a terminal:

git --version
# git version 2.45.2

The exact number you see will be whatever is current when you install; any recent 2.x release is fine for this course.

Git Repository

A Git repository ("repo") is the storage that holds your project's files together with the complete history of every change. The history lives in a hidden .git folder at the root of the project.

You create a repository in one of two ways — start a fresh one with git init, or copy an existing remote one with git clone:

# Turn the current folder into a new, empty repository
git init
# Initialized empty Git repository in /path/to/project/.git/

# Or download an existing project and its full history
git clone https://github.com/user/project.git

SSH Key

An SSH key is an access credential used by the SSH protocol (Secure Shell). SSH is a network protocol that lets you log in from one computer to another securely over an untrusted network.

In Git, an SSH key pair (a private key you keep secret and a public key you upload to GitHub, GitLab, etc.) lets you push and pull without typing your password every time. The SSH key chapter walks through generating a key and adding it to your account.

Practice

Practice
Which of the following is a feature of Git as a Version Control System?
Which of the following is a feature of Git as a Version Control System?
Was this page helpful?