Understanding Git

Posted on 2013-12-28 04:20:24 +0900 in Technology Git

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.

alt normal

Figure 1-1. VCS usually only stores the differences.

alt normal

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.

alt normal

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.

alt normal

Figure 1-4. Tree object

alt normal

Figure 1-5. Content structure of the tree object.

alt normal

Figure 1-6. Single commit in a compatible way.

The Git directory

The Git tree structure is as follows:

alt normal

Figure 1-7. Git directory

alt normal

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.

alt normal

Figure 1-9. Git branch

alt normal

Figure 1-10. Git head.

Reference

[1] Visual git tutorial

[2] Git tutorial

----------------------------------- 本文内容遵从CC版权协议转载请注明出自kamelzcs -----------------------------------
«  | Vim Tips »

Hide Comments

comments powered by Disqus