Git terminology explanation Staging,index,cache

Source: Internet
Author: User
Tags using git

When I was using git, there were three things that bothered me a lot, title, Staging,index, and cache.

For example, when I read the ebook "Pro git" from the Git website, I mentioned in the first chapter that the file is in git with three states, working copy,staging area, and in repository. While reading some man pages, such as the Git-reset command, will see index, which is very disturbing. And the GIT-RM directive has a parameter called-cached, its role is "unstage and remove paths only from the index", more strange, but also mentioned the stage and index, and the name of the parameter is cached!!!

What happened to the three of them? It is extremely important for me to be clear about these problems for me who like root planing. By Google, I found a small Japanese brother named Junio C Hamano, who is one of the core maintainers of Git and tells the story of the three of them. The main content of this article from the article read out, add some of their own understanding, not cold classmates, please read the original text directly.

After reading the original text, my basic feeling is that these are the Linus of the Great God at the time of the an idea away and the name of the arbitrary problem.

Originally, Linus when maintenance kernel, used a kind of "Tarball and Patches" workflow model (what ghost? ), the specific principle does not understand, I understand the meaning, he wants to study each kernel patch to kernel exactly what influence. For example, he has a 2.6.12 tarball, and patch-1,patch-2 two, so he has to at least get out three new versions, 2.6.12-patch1,2.6.12-patch2,2.6.12-patch1&2. A mere two patches made 3 new versions, if patches were overwhelmed.

So, he invented a "directory cache", in fact, is the concept of the tree in Git today, each node on the tree is a kernel of the entire directory structure and files (in a highly compressed form). The way to build this tree is to add content to the cache caches, or update the contents of cache caches.

The directory used to store the tree structure, called ". Dircache" (now called ". Git"). In this directory, there is a file called index, in the Git source code (written in c), the operation of the index variable name, there is a prefix called "cache". The purpose of this index file is to decide what files you will eventually write to that tree structure, and index is the buffer for staging. (as can be seen, this tree structure, its fundamental role is to maintain a huge amount of version, in fact, is the GIT repository itself) Everyone in the development team mixes the cache and index two words because the file name of the record buffer (cache) content is called index. If you are given a file path, you can find the content you want to submit from the index file (and it still does).

Now, more and more people, do not need to read the Git source, you can use Git (because of the document and a lot of books, from the application level to introduce a lot of git knowledge, so do not need to find all the secrets from the Source: D). Therefore, the name of index is becoming more and more popular, because this file will appear in the. git directory, and in the source code, those variables at the beginning of the cache are not known. Ultimately, we (the GIT development team) no longer use the word cache to explain the problem to the small white user (end user), but the word cache is used when we talk about git internal data structures and GIT implementations.

For small white users, now the word "cache" in the form of past participle cached, its part of speech is an adjective. Indicates that the content to be discussed is currently in the index file, not in the working directory (work tree). (If I changed a file in the working directory, using the Git-add command, I modified the content-the equivalent of a patch--will appear in the index, but in my working directory, of course, I still have to modify the content, but is superimposed on the repository of the file). Of course, we can also use the word "indexed", but "cached contents", in English is a phrase, already exist, the expression is this meaning, so we do not need to invent a word to illustrate this meaning, using the cached (I went to Ah >-

Git terminology explanation Staging,index,cache

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.