SHA vs. GUID
From The Git Object Model, emphasis is mine:
- Git can quickly determine whether two objects are identical or not, just by comparing names.
- Since object names are computed the same way in every repository, the same content stored in two repositories will always be stored under the same name.
- Git can detect errors when it reads an object, by checking that the object's name is still the SHA1 hash of its contents.
So, yes, it is a protection against corruption. And that's why GUID won't work - it is random and does not depend on contents.
Checksums of what?
Also from the same article:
It is important to note that this is very different from most SCM systems that you may be familiar with. Subversion, CVS, Perforce, Mercurial and the like all use Delta Storage systems - they store the differences between one commit and the next. Git does not do this - it stores a snapshot of what all the files in your project look like in this tree structure each time you commit. This is a very important concept to understand when using Git.
Git stores binary snapshots, but not deltas, in
blob objects. Directory structure and file names are stored in
tree objects. Good explanation can be found here: Git Internals - Git Objects
Git calculates SHA checksums of this objects, not deltas or original files.
blobs contain only contents of original files, while names of those files go into
If you want to learn git as a user, you don't have to know about internals. At the moment, I've been using Git for over 3 years and haven't used any of this information in practice even once. It's good to know, but not required.
If you're interested in general architecture of Git, read this: Git in The Architecture of Open Source Applications.