Git tutorial (Three) Quest ".git" directory

Disclaimer: This article is a blogger original article, shall not be reproduced without the bloggers allowed. https://blog.csdn.net/young2415/article/details/89528504


Every Git repository will have a ".git" directory, which is the core of Git repository, version information and stores configuration information for the warehouse. Today, let us look at what the secret has ".git" directory.

Just open a warehouse ".git" directory, you will find that there will be several such files and folders:
Here Insert Picture Description

A, HEAD file

HEAD file stores the current working branch. Look at the contents of the file:
Here Insert Picture Description

This represents the beginning of the ref is a reference, but where does this reference point, point refs / head / master this path.

And then look at the branch:
Here Insert Picture Description

Git HEAD file is based on this work to determine the current branch. If you switch the current branch, the contents of this file will also change.

Two, refs folder

heads

From the previous section we know, HEAD file stores the current working branch, which is actually a path: refs / heads / master. So refs folder is doing, and we went inside to check it out. Came .git / refs / heads directory, found that there are two files, master and temp, which is two branches of our current warehouse. Respectively, look at the contents of the master and temp files:
Here Insert Picture Description

Files stored in a string of hash. Each string hash value is actually pointing to an object, git cat-file -t 哈希值you can view the type of object that points to the hash value of the order.
Here Insert Picture Description
The results show, that the hash value string of a commit point is the object type.

Note that I'm looking at the hash value points to the object type, and did not use the full hash value, the original complete hash value is "783bbca61fea9dcd8e1b0ba3e7bb8cc8d5bb2a61" I only used the first few characters of the string of hash values "783bbca" actually can show normal results, because if this had been the first few characters are unique, then Git can find the corresponding object based on these characters without the need to use the full hash.

And when we look at the branch,
Here Insert Picture Description
will find this point to commit the current master is also a hash value of 783bbca. temp is the same. It can be seen, refs / heads of this path is stored commit object currently pointed each branch.

tags

refs followed by a folder called tags.

tag is equivalent to a milestone project for the more important commit, such as project released version 1.0 of the time, this will commit marked with a tag, which is tag. tags below this folder will be stored in the warehouse all the tag, each tag files are stored with a hash value, point is marked with the label commit object.

Three, config file

config file stores the configuration information in the local warehouse. Look at the contents of the file:
Here Insert Picture Description
there is some configuration information is stored, if we modify the contents of this document, for example, I put the user name changed supermouse666, and then go to check the configuration, you will find the user name has changed.
Here Insert Picture Description
Vice versa, if you use Git commands modify the local repository user name, then the file content changes also occur. For example, I put mail into [email protected]
Here Insert Picture Description
Here Insert Picture Description

Four, objects folder

The figure is objects folder some children file stored inside the folder, wherein ① part are objects stored, and ② portion inside the pack folder special, its role is, when the warehouse more loose object file when , Git will automatically do the sort, these files are packaged loose objects into the pack folder.
Here Insert Picture Description
Just open a folder, which kept the object file.
Here Insert Picture Description
Folder name + file name will form a hash value, the hash value to an object, look at the type of the object:
Here Insert Picture Description
It is an object of type blob, that a file object. You can use git cat-file -p 哈希值this command to view the contents of the object.
Here Insert Picture Description
We can see the contents of the code file but in fact what we submitted.

Guess you like

Origin blog.csdn.net/young2415/article/details/89528504