What Git Is: Version Control, Snapshots and Distributed Repositories
What version control solves, how Git stores a project as a chain of snapshots, why every clone holds the full history, how Git differs from GitHub and GitLab, the vocabulary used in this course, and how to run the examples in the page.
kvi5hnuCode Sprout team member11 min readOn this page
Every project changes. Files are added, rewritten and deleted, by one person or by dozens. Without a tool to track those changes, questions like these get hard to answer:
- What did this file look like last Tuesday, before something broke?
- Who changed this line, when, and why?
- Can two people work on the same files at once without overwriting each other?
- Can I try a risky idea without damaging the working version?
A version control system answers them. It records the history of a set of files, so you can see every past version, compare versions, undo changes and combine work from several people. Git is by far the most widely used version control system today: the Linux kernel, most open-source projects and most companies' code live in Git repositories.
This article explains the ideas behind Git before the commands. Then it runs a short tour, so you can see a real repository being built in the page.
Snapshots, not lists of changes
Many older systems stored a file's history as a list of changes: version 1, then "add these lines", then "remove those lines". Git takes a different view. Each time you commit, Git records a snapshot of the whole project, every tracked file as it is at that moment. A file that didn't change isn't stored again: the new snapshot simply points to the copy already saved. Each commit also points back to the commit before it, its parent, so the commits form a chain: the project's history.

Two consequences follow:
- Switching versions is fast. Going back to an old commit just means restoring that snapshot's files. Git doesn't have to apply a long list of changes in reverse.
- Every commit has a unique ID computed from its contents: a hash such as
e94b51c.... The ID covers the files, the message, who made the commit and when, and the parent commit. Changing anything in an old commit, even one character, would produce a different ID, so history can't be altered silently. Git notices if stored data is corrupted.
Git still shows you differences whenever you ask, such as "what changed in this commit?", by comparing two snapshots.
Distributed: every clone is a full repository
In a centralized system, such as Subversion, the history lives on one server, and each developer has only a working copy of the latest files. Viewing history or committing needs a connection to that server.
Git is distributed. When you clone a repository, you get the whole history: every commit, every version of every file. Your copy is a complete repository in its own right. That means:
- Committing, viewing history, comparing versions and creating branches all happen locally. They're fast and work offline.
- Every clone is effectively a backup of the project.
- Sharing is a separate, explicit step: you push your commits to another repository and fetch or pull other people's commits from it.
Teams still usually agree on one shared repository, often hosted on a service such as GitHub, as the place where everyone's work comes together. That's a convention, not something Git requires: any repository can exchange commits with any other.
Git is not GitHub
Git is the version control tool: a program you run on your own computer. It's free and open source.
GitHub, GitLab, Bitbucket, Azure DevOps and others are hosting services built around Git. They store repositories on their servers and add features for teams, such as pull requests (proposing and reviewing changes), issue tracking, access control and automated builds (CI). You can use Git without any of them, and a repository can move between them easily, because each one stores an ordinary Git repository.
A short history
Git was created by Linus Torvalds in April 2005, for developing the Linux kernel, after the kernel project lost free access to the commercial system it had been using. The goals were speed, strong protection against corrupted or tampered history, and support for thousands of developers working in parallel. Junio Hamano has maintained Git since July 2005. Version 1.0 was released in December 2005 and version 2.0 in May 2014. New versions come out every few months. This course uses Git 2.56, the current release, and points out what changes in the planned Git 3.0.
The vocabulary you'll meet
| Term | Meaning |
|---|---|
| repository (repo) | a project's files plus their complete history. The history lives in a hidden .git folder |
| working tree | the ordinary files you see and edit in the project folder |
| commit | a saved snapshot of the project, with a message, an author, a date and a link to its parent |
| staging area (index) | where you prepare the next commit: you choose which changes go into it |
| branch | a named line of development: a movable label pointing at a commit |
| HEAD | Git's name for "where you are now": usually the branch you're working on |
| remote | another repository yours exchanges commits with, usually named origin |
| clone | a full copy of a repository, history included |
| push / fetch / pull | send commits to a remote / download commits from it / download and combine them with your work |
| merge / rebase | two ways of combining work from different branches |
Each term gets its own article. Article 4 explains the working tree, staging area and repository in detail, because almost everything else builds on them.
How the examples in this course work
Most examples are runnable: press Run and the script executes in a sandbox with Git 2.56 installed. The output appears below the example, and you can edit the script and run it again. A few things about the sandbox:
- Each run starts from an empty folder. Scripts create their own repositories, usually with
git init, so examples can be run in any order. - Git is already configured with the name
Sam Leeand the emailsam@example.com, so commits work straight away. Article 2 shows how to set your own identity on your computer. - The clock is fixed at 2 March 2026, 10 UTC, for every commit. Because a commit's ID depends on its date, this makes the IDs in the output identical every time you run an example. On your own computer, the same commands produce different IDs, because the dates and author differ. That's expected.
- There's no network. Examples that need a server use another folder on the same machine as the "remote", which works the same way as GitHub for Git's purposes.
- Error messages are part of the output. Some examples deliberately run a command that fails, such as a merge with a conflict, to show what Git says.
Here's a first taste. Don't worry about the details yet: the next articles explain every command. The script creates a repository, commits two versions of a file, and then asks Git about the history:
git init trail-guide
cd trail-guide
echo "Trail guide: maps and notes for local hikes" > README.md
git add README.md
git commit -m "Add README"
echo "Start with the Ridge loop: 8 km, mostly flat." >> README.md
git commit -am "Recommend a first trail"
echo "--- history"
git log --oneline
echo "--- what changed in the last commit"
git show --stat --oneline HEAD
echo "--- the file as it was in the first commit"
git show HEAD~1:README.md
Initialized empty Git repository in /workspace/trail-guide/.git/
[main (root-commit) 18874a8] Add README
1 file changed, 1 insertion(+)
create mode 100644 README.md
[main 6e999a8] Recommend a first trail
1 file changed, 1 insertion(+)
--- history
6e999a8 Recommend a first trail
18874a8 Add README
--- what changed in the last commit
6e999a8 Recommend a first trail
README.md | 1 +
1 file changed, 1 insertion(+)
--- the file as it was in the first commit
Trail guide: maps and notes for local hikes
git log --oneline lists the two commits, newest first, each with the start of its ID. HEAD~1 means "one commit before the current one", so the last command printed the README as it was in the first snapshot, although the file on disk has moved on. That's version control in one line: every saved version is still there.
What's current
- Git 2.56 (October 2026) is the current release. Git ships a new version roughly every 8 to 12 weeks, and old versions keep working with new ones: a repository created years ago opens in today's Git.
- Git 3.0 is planned but has no release date. Its main changes for new repositories are SHA-256 IDs instead of SHA-1 (article 50), a new storage format for branch names called reftable, and
mainas the default branch name instead ofmaster. Git 2.52 and later already print a hint about the branch-name change when you create a repository without choosing a name. - Hosting services keep adding features such as merge queues, code review tools and AI assistants. Those features sit on top of the hosting service. Git itself, the commands this course teaches, works the same everywhere.
Common questions
Do I need GitHub or an internet connection to use Git? No. Git works entirely on your computer: you can create repositories, commit, branch and view history offline. A hosting service is only needed when you want to share a repository with other people or keep a copy on a server.
Is Git only for code? No. Git tracks any files, and works best with text: documentation, configuration, websites, data in CSV or JSON, books written in Markdown. Large binary files, such as videos or design files, work but are stored inefficiently. Article 43 covers Git LFS, which is designed for them.
Is Git hard to learn?
The everyday commands, add, commit, push and pull, take an afternoon. Git feels hard when its model isn't clear: what a commit is, what a branch really is, and where your changes are at any moment. This course explains that model early (articles 4 and 11) and comes back to it throughout, because once it's clear, the commands make sense.
What's the difference between a centralized and a distributed version control system? In a centralized system, such as Subversion or Perforce, one server holds the history and clients talk to it for most operations. In a distributed system, such as Git or Mercurial, every clone holds the full history, so most operations are local and any repository can share commits with any other.
Are commit IDs secure if they use SHA-1? Git uses a hardened SHA-1 that detects the known collision attacks, and the attacks are expensive. Git also supports SHA-256 repositories today, and Git 3.0 plans to make SHA-256 the default for new repositories. Article 50 explains the details.
Summary
- A version control system records the history of a set of files, so you can view, compare and restore past versions and combine work from several people.
- Git stores history as a chain of snapshots called commits. Each commit has an ID computed from its contents and points to its parent.
- Git is distributed: every clone holds the complete history, so most operations are local and offline, and sharing is done explicitly with push and fetch.
- GitHub, GitLab and similar services host Git repositories and add team features. Git itself is the tool on your computer.
- The runnable examples use a sandbox with a fixed identity and clock, so commit IDs match the output shown. On your computer, the IDs will differ.
Practice questions
A colleague says: "Git saves a list of the changes in each file, so going back to an old version means undoing every change since." What's inaccurate about that?
Answer
Git stores each commit as a snapshot of all tracked files, with unchanged files shared between snapshots rather than copied. Restoring an old version means restoring that commit's snapshot directly, not undoing later changes one by one. Differences are computed on demand by comparing two snapshots. (Internally, Git does compress similar file versions against each other in its packfiles, article 50, but that's a storage detail, not the model.)
Your laptop is offline on a train. Which of these can you do with your Git repository: commit, view the history of a file, create a branch, push to GitHub, compare two old versions?
Answer
Everything except pushing. Committing, viewing history, creating branches and comparing versions are local operations, because your clone contains the full history. Pushing sends commits to another repository, so it needs a connection. You can push the commits you made offline later.
In the runnable example, why does git show HEAD~1:README.md print only one line, although README.md on disk has two?
Answer
HEAD~1 is the commit before the current one, the "Add README" commit. HEAD~1:README.md asks for the file as it was recorded in that snapshot, when it had only its first line. The second line was added in the later commit. Git keeps both versions, and the file on disk shows the latest.
Previous: Git Course Outline: From First Commit to Git Internals
Next: Installing Git and First-Time Setup: Identity, Editor, Default Branch and Help

More in Git Course
Quiz: Git Delicate Details
Twenty-five questions on Git's subtle corners: what commit -a and stash leave out, empty folders, ignore patterns and negation, HEAD~ versus HEAD^, ours and theirs in a rebase, tags that don't move or don't push, describe, merge reverts, diff exit codes, stash conflicts and more.
Quiz: Git Interview Questions
Thirty Git questions of the kind asked in developer interviews: Git versus GitHub, the staging area, merge versus rebase, fetch versus pull, reset, revert and restore, detached HEAD, conflicts, force pushing, stash, cherry-pick, reflog, bisect, submodules, LFS and how commits are identified.
Quiz: Git Course Final Exam (All Parts)
The final exam for the Git course: thirty questions across all twelve parts, from the three areas and staging through branching, remotes, undoing, history investigation, configuration, tags, larger projects, patches, rewriting, internals and troubleshooting.
Quiz: Professional Git Practice (Git Part 12)
Sixteen questions on migrating to Git from Subversion, TFVC and Mercurial, team best practices for commits, branches and reviews, repository hygiene, and diagnosing and fixing the most common Git errors, with explanations.
Discussion
Sign in to ask a question or share what you learned.