[Gllug] git "snapshots"

Iain Conochie iain at shihad.org
Tue Apr 5 17:02:57 UTC 2011


On 05/04/11 17:33, gvim wrote:
> This is probably rather basic but bear with me. I'm trying to get my 
> head round git and hear constant references to the term "snapshot" 
> without any explanation of what such an entity contains other than 
> unhelpful photographic analogies.

A snapshot is a point-in-time. For example you have a directory with 4 
files in it. When you stage and then commit these files you now have a 
snapshot of the whole directory tree as it was at the point-in-time you 
made the commit. Remember git tracks changes, using SHA1 hashes of each 
file / directory (blob) in your working directory, so when a blob 
changes the SHA1 will obviously change and hence git knows about it

> Apparently git is based on snapshots of the working directory but does 
> that mean a complete copy of the whole directory is made during a commit? 

No. Only the files that have changed. That is why you stage them first 
(git add). However you _first_ commit will add the whole directory (and 
sub directories). Remember git commits the entire file as a blob, not 
just the changes

> If so, the disk usage would be huge so I suspect this is not what a 
> snapshot refers to. Too often I find git terminology is explained with 
> other git terminology so not helpful to new users.

Come come now - when has _anything_ useful on UNIX been helpful to new 
users ;)

Cheers

Iain

>
> gvim
> -- 
> Gllug mailing list  -  Gllug at gllug.org.uk
> http://lists.gllug.org.uk/mailman/listinfo/gllug

--
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list