What is a git "Snapshot"?

The official Git doc says:

$ git diff test

This will show you what is different between your current working directory and the snapshot on the 'test' branch

As a newbie this is very confusing. I've never heard of the term snapshot. Do they mean the "HEAD" of the "test" branch?


The term snapshot is used in the git reference site as well

It is the replacement term for "Revision". In other version control systems, changes to individual files are tracked and refered to as revisions, but with git you are tracking the entire workspace, so they use the term snapshot to denote the difference.

From http://gitref.org/index.html

Instead of writing a tool that versions each file individually, like Subversion, we would probably write one that makes it easier to store snapshots of our project without having to copy the whole directory each time.

This is essentially what Git is. You tell Git you want to save a snapshot of your project with the git commit command and it basically records a manifest of what all of the files in your project look like at that point. Then most of the commands work with those manifests to see how they differ or pull content out of them, etc.

If you think about Git as a tool for storing and comparing and merging snapshots of your project, it may be easier to understand what is going on and how to do things properly.


A snapshot is the state of something (e.g. a folder) at a specific point in time. In this case, snapshot means the current content of the test branch, this doesn't have to be the head revision.


In order to explain the term snapshot clear. Please allow me to introduce the other two things

  1. git loose object format
  2. git Packfiles

Assume we have a file called "a.txt" which contents are ten 'a' letters under git control. After we commit this file, it will create three folders under .git/objects path and each folder has one file. Each file is S.N.A.P.S.H.O.T.

a.txt file under git control which has been committed three folders created by git after committed

Each folder has one file

enter image description here

Now we edit the a.txt file to see what happens

We changed the first letter 'a' to letter 'b'

enter image description here-->> enter image description here

Then committed!

Git created other three new files under three new folders

enter image description here

These three new files are also S.N.A.P.S.H.O.Ts

enter image description here

Every time we do COMMIT git will save snapshots to disk instead of the delta between the new version to the old version of the same file. Even if we just changed one letter of one file, git will save the whole file as a snapshot.

This also called the loose object format.

In this case, git will cost more disk space than the other vcs(such as subversion) which saves delta between the new version to the old version of the same file. But the benefits of using snapshot shorten the time at commit stage.

But the brilliant git will do another jobgit gc after this from time to time which created PACKFILES and removes the snapshot which contents are similar to shrink the size of itself. After these workgit gc, the disk cost by git will just like the other VCS which uses delta ways.

Through snapshot and git gc. Git will faster than other VCS which use delta ways at commit stage and costed the disk size just be similar to the other VCS that use delta ways.

Git finds a balanced way between the performance and disk space cost.

GIT is best

The packfiles is under .git/objects/pack

You can see it after execute "git gc" command by yourself.


Snapshot is to a repository as screenshot is to a video.

It's the content (files and folders) of a repository at some point in time.

When you commit, you save your repository's current working directory as a new snapshot (commit = snapshot + metadata). Your Git repository consists of series of snapshots (commits), other VCS consists of series of diffs instead.