Understanding Git
Posted on 2013-12-28 04:20:24 +0900 in Technology
What is in Git is snapshots
The most obvious feature in Git owns all the snapshots of the system, while most other VCS system only stores the differences.
Figure 1-1. VCS usually only stores the differences.
Figure 1-2. Git stores the snapshots.
In order to get data efficienty, the Git compresses each ‘original’ file and calculate its SHA-1
hash, then use a tree structure to store the whole infomition hierarchically.
The three states in Git
In Git, there are three states: the working directory, staging area and Git directory.
Figure 1-3. Git states
The basic working flows is as follows:
-
Making changes in working directory.
-
Stage the useful changes and add their snapshots to the staging area.
-
Commit the staging area to the Git directory, which will store the snapshots of the staging area permunantly.
How the Git store the snapshots
The Git tree object
The Git store thing similar to the Unix system: the tree object corresponds to the directory entity while the blog corresponds to the inode or file.
Figure 1-4. Tree object
Figure 1-5. Content structure of the tree object.
Figure 1-6. Single commit in a compatible way.
The Git directory
The Git tree structure is as follows:
Figure 1-7. Git directory
Figure 1-8. Git directory in a compatible way.
The Git branch
The Git branch is a pointer to a commit, the HEAD is the pointer to your current branch.
Figure 1-9. Git branch
Figure 1-10. Git head.
Reference
[2] Git tutorial