Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a git "Snapshot"?

Tags:

git

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?

like image 383
jens Avatar asked Feb 10 '11 23:02

jens


People also ask

What is a commit snapshot?

A commit is a snapshot in time. Each commit contains a pointer to its root tree, representing the state of the working directory at that time. The commit has a list of parent commits corresponding to the previous snapshots. A commit with no parents is a root commit and a commit with multiple parents is a merge commit.

Where are git snapshots stored?

Git doesn't think of or store its data this way. Instead, Git thinks of its data more like a set of snapshots of a mini filesystem. Every time you commit, or save the state of your project in Git, it basically takes a picture of what all your files look like at that moment and stores a reference to that snapshot.


1 Answers

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.

like image 92
philippe Avatar answered Sep 21 '22 19:09

philippe