Skip to content

Version Control: Definition, Git and a Simple Example

Quick answer

What version control is, how local, centralised and distributed systems differ, how Git fits in, and a short Bash session that makes two commits.

Version Control: Definition, Git and a Simple Example

Version control is a system that records changes to a file or set of files over time so that you can recall specific versions later. Git is a widely used version control tool: a distributed system that keeps the full history of a project on every developer's machine. It differs from a backup because it records what changed and why.

Key takeaways

  • Version control records changes over time, so you can return to an earlier version.
  • Pro Git describes three kinds: local, centralised and distributed.
  • Git is distributed; GitHub is a separate service that hosts Git repositories.
  • Even a solo learner benefits: two commits are enough to see the history.

On this page:

TypeWhere the history livesExamples named by Pro Git
Local VCSA simple database on one machineRCS
Centralised VCSA single server; clients check out filesCVS, Subversion, Perforce
Distributed VCSEvery clone mirrors the full repository and historyGit, Mercurial, Darcs

What does version control mean?

Pro Git, the free book hosted at git-scm.com by Scott Chacon and Ben Straub, defines version control as a system that records changes to a file or set of files over time so that you can recall specific versions later. It explains that programmers developed local systems, with a simple database of changes, to deal with manual copying of files.

Centralised systems have a single server holding all versioned files, which clients check out from. In a distributed system, Pro Git says clients do not just check out the latest snapshot; they fully mirror the repository, including its full history.

How does version control work?

The Git user manual calls Git a fast distributed revision control system. It stores history as a compressed collection of interrelated snapshots of the project's contents, and each such version is called a commit.

Here is a first session you can run in Bash. If Git asks who you are, set user.name and user.email with git config first.

git init notes-project
cd notes-project
echo "Day 1 notes" > notes.txt
git add notes.txt
git commit -m "Add day 1 notes"
echo "Day 2 notes" >> notes.txt
git commit -am "Add day 2 notes"
git log --oneline

The last command lists two commits, newest first. Each line is a saved version you can return to.

Where is version control used?

Software teams use it for code, and others use it for documents, data and configuration. Illustrative student scenario: a fresher keeps three versions of a resume and a project report in files named final, final2 and final_new. With Git, one folder and git log replace that clutter, and an earlier version can be recalled.

Git is released under the GNU General Public License version 2.0, an open source licence, according to the Git project. For commands, read introduction to Git commands. To share work online, see everything you need to know about GitHub.

What are the common mistakes and confusions?

  • Mixing up Git and GitHub. Git is the tool that records versions; GitHub is a hosting service for Git repositories.
  • Treating it as a backup. A backup copies files; version control records each change as a commit you can inspect.
  • Vague commit messages. "update" tells you nothing six weeks later. Say what changed.
  • Waiting to commit. Small, frequent commits make it easy to find the change that broke something.

Repository, commit, branch, merge, clone and remote are the core vocabulary. Once you are comfortable, build a public profile: how to build a GitHub profile README and how to build a GitHub portfolio.

Next step

Run the session above, then add a third commit and read the log again. Next, push the folder to a free GitHub repository so your work is visible.

Frequently asked questions

What is version control?

Version control is a system that records changes to a file or set of files over time so you can recall specific versions later, according to Pro Git. Git is a widely used example.

What is Git and how is it different from GitHub?

Git is a distributed version control tool that records your project history. GitHub is a hosting service for Git repositories, adding sharing and collaboration on top.

What is a commit?

A commit is one saved version of a project. The Git user manual says Git stores history as a collection of interrelated snapshots, and each such version is called a commit.

What is the difference between centralised and distributed version control?

Centralised systems keep all versioned files on one server. In distributed systems such as Git, each clone fully mirrors the repository, including its full history.

Do I need Git if I work alone?

It still helps. You can recall earlier versions, see what changed and experiment safely. Even a two-commit practice project teaches the habit.

Share LinkedIn X WhatsApp
×

Our Courses

Practice-Based Learning Tracks, Supercharged By A.I.