In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
1. Object type
The git object library is the core of the implementation of the Git version library, which contains the original data file and all the log information, author information, date, and other information used to rebuild any version or branch of the project. Located in the .git / objects directory.
├── HEAD ├── branches ├── config ├── description ├── hooks │ ├── pre-commit.sample │ ├── pre-push.sample │ └──... ├── info │ └── exclude ├── objects │ ├── info │ └── pack refs heads tags
There are four types in the git object library: blocks (blob), directory trees (tree), submissions (commit), and tags (tag). These four atomic objects form the basis of the high-level data structure of Git.
The addressing of git objects is represented by a 40-bit hexadecimal number, that is, SHA1 or hash code, such as 7f8aacaddffe009fff75b81187527c35a51f3eac. For administrative convenience, the first two bits in the file system are used as the name of the folder, and the last 38 as the name of the file.
You may feel that using 40-bit addressing ID as git objects, there may be different content but the same hash code, your feeling is correct, but the probability of this situation is certainly negligible.
The relationship between the objects is as follows:
2. Blob block
The blob object stores the time content of the file, which is actually the file content of the workspace. Specifically, use the zlib algorithm to compress the file content, and then take the hash algorithm for the resulting bytes. So the same file content, the resulting blob object must be the same.
Example:
Git init temp-initialize an empty git repository cd tempecho "Welcome to git" > hello.txtgit add hello.txt-add to register
At this point, we look at the .git / objects directory as follows:
At this point, we can view the contents of the git object through the git cat-file command. Note that the cat-file command can view all git objects. This command can view all git objects.
Git cat-file-p b08a2810d8a4542f350f650435f506c6c81ca9b2Welcome to git
Because git uses compression on the file content and then takes hash as the file name, no matter how many copies of the same file content there are in the file system, only one is stored in the git object.
3. Directory Tree tree
The git directory tree object maps the directory of the workspace in the operating system, except that the directory of the workspace is a collection of files and folders, while the directory tree object is a collection of blob objects and directory tree objects.
Mkdir srccd srccp.. / hello.txt hello.txtgit add hello.txtgit write-tree-git internal command, commit command is basically equal to write-tree and commit-tree command
At this point, we use the hash value returned by the write-tree command using the cat command
You can see from the figure that the file with the same content, the blob is the same, and the command tree tree object is a mapping of the folder of the corresponding file system.
4.commit submission
Submission is a common action when we use git, and each submission executes a directory tree object. At the same time, the submission has one or more parent submissions. Let's now use the commit-tree command to associate the directory tree object (usually use the commit command to automatically create the tree object and associate the parent submission).
We can use git $command-- help to view the command documentation, such as git commit-- help, git pull-- help
Git commit-tree 5657a3b1d1454667d51f8c64c1fe9830276cdcea-m "1 commit"-first submission so no parent submission 7df70363051681bdd078b6a1a3fc9fe3d1595325-returns the Hash value of the commit object git cat-file-p 7df70363051681bdd078b6a1a3fc9fe3d1595325tree 5657a3b1d1454667d51f8c64c1fe9830276cdceaauthor xxxxxxx 1516538936 + 0800committer xxxx 1516538936 + 08001 commit
Note that when we use the git log command at this point, we don't show the submission we just made, but we need to merge it into the master branch using the git merge 7df70363051681bdd078b6a1a3fc9fe3d1595325 command. You can see that the git commit command is basically the same as the write-tree commit-tree merge command.
Now let's modify the hello.txt command in the workspace and then submit the contents of the directory tree for viewing.
Notice that the tree object is the same as the tree object corresponding to the first commit team, which is e15a40c68bd15301b60d21c204a5e7a87d62d8a1, and we haven't modified anything under its folder. The content of the blob object 32690ead83f3b77ad763e9e2c2e60ce3706cf117 is two lines, indicating that the internal submission of the specified tree object within the git object is a snapshot of the workspace, not a stored increment (otherwise the content is the line you just added).
5. Label tag
The tag is just a snapshot of the submission, and its contents are not allowed to be modified.
Git tag 1.0$ git cat-file-p 1.0tree f935b24b9a688ba5050fda30d70801c9092caeaaparent 7df70363051681bdd078b6a1a3fc9fe3d1595325author xxx 1516542403 + 0800committer xxx 1516542403 + 08002 commit6.F&Q1.git Encoding
Git's blob objects are stored using byte streams, so there is no coding problem.
UTF-8 encoding is used by default for the path corresponding to the directory tree object and the message comment corresponding to commit.
If you want to change the encoding format, please refer to (unless there is a special reason): https://git-scm.com/docs/git-commit/1.8.0.1#_discussion
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.