Five, Git basic principles

1 hash

Insert picture description here

  • Hash is a series of encryption algorithms. Although different hash algorithms have different encryption strengths, they have the following common points:
    ① No matter how large the amount of input data is, input the same hash algorithm to get the length of the encryption result fixed.
    ②The hash algorithm is determined, the input data is determined, and the output data can be guaranteed to be unchanged.
    ③The hash algorithm is determined, if the input data changes, the output data must change, and usually changes greatly.
    ④The hash algorithm is irreversible. The
    underlying Git uses SHA- 1 Algorithm.
    Hash algorithms can be used to verify files. The principle is shown in the figure below:
    Insert picture description here
    Git relies on this mechanism to fundamentally ensure data integrity.

2 Git save version mechanism

2.1 File management mechanism of centralized version control tools

Store information in the form of a file change list. Such systems view the information they save as a set of basic files and the cumulative differences of each file over time.
Insert picture description here

2.2 Git's file management mechanism

Git treats data as a set of snapshots of a small file system. Every time an update is submitted, Git will make a snapshot of all current files and save the index of this snapshot. For efficiency, if the file is not modified, Git will not re-store the file, but only keep a link to the previously stored file. So the way Git works can be called a snapshot stream.
Insert picture description here

2.3 Git file management mechanism details

  • Git's "submit object"
    Insert picture description here
  • The chain formed by the submitted object and its parent object
    Insert picture description here

3 Git branch management mechanism

3.1 Branch creation

Insert picture description here

3.2 Switching of branches

Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here

Guess you like

Origin blog.csdn.net/Lu1048728731/article/details/115268036