Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The Git book contains an article on <a href="http://shafiulazam.com/gitbook/7_the_git_index.html" rel="noreferrer">what an index includes</a>:</p> <blockquote> <p>The index is a binary file (generally kept in <code>.git/index</code>) containing a sorted list of path names, each with permissions and the SHA1 of a blob object; <code>git ls-files</code> can show you the contents of the index:</p> </blockquote> <pre><code>$ git ls-files --stage 100644 63c918c667fa005ff12ad89437f2fdc80926e21c 0 .gitignore 100644 5529b198e8d14decbe4ad99db3f7fb632de0439d 0 .mailmap </code></pre> <p>The <a href="http://www.kernel.org/pub/software/scm/git/docs/technical/racy-git.txt" rel="noreferrer">Racy git problem</a> gives some more details on that structure:</p> <blockquote> <p>The index is one of the most important data structures in git.<br> It represents a virtual working tree state by recording list of paths and their object names and serves as a staging area to write out the next tree object to be committed.<br> The state is "virtual" in the sense that it does not necessarily have to, and often does not, match the files in the working tree.</p> </blockquote> <hr> <p>To see more, cf. "<a href="https://github.com/git/git/blob/master/Documentation/technical/index-format.txt" rel="noreferrer"><strong>git/git/Documentation/technical/index-format.txt</strong></a>":</p> <h2>The Git index file has the following format</h2> <blockquote> <p>All binary numbers are in network byte order.<br> <strong>Version 2</strong> is described here unless stated otherwise.</p> <ul> <li>A 12-byte header consisting of: <ul> <li>4-byte <strong>signature</strong>:<br> The signature is { '<code>D</code>', '<code>I</code>', '<code>R</code>', '<code>C</code>' } (stands for "<strong><code>dircache</code></strong>")</li> <li>4-byte <strong>version number</strong>:<br> The current supported versions are 2, 3 and 4.</li> <li>32-bit number of index entries.</li> </ul></li> <li>A number of sorted <strong><a href="https://github.com/git/git/blob/867b1c1bf68363bcfd17667d6d4b9031fa6a1300/Documentation/technical/index-format.txt#L38" rel="noreferrer">index entries</a></strong>.</li> <li><strong>Extensions</strong>:<br> Extensions are identified by signature.<br> Optional extensions can be ignored if Git does not understand them.<br> Git currently supports cached tree and resolve undo extensions. <ul> <li>4-byte extension signature. If the first byte is '<code>A</code>'..'<code>Z</code>' the extension is optional and can be ignored.</li> <li>32-bit size of the extension</li> <li>Extension data</li> </ul></li> <li>160-bit SHA-1 over the content of the index file before this checksum.</li> </ul> </blockquote> <hr> <p><a href="https://stackoverflow.com/users/1483503/mljrg">mljrg</a> <a href="https://stackoverflow.com/users/1483503/mljrg">comments</a>:</p> <blockquote> <p>If the index is the place where the next commit is prepared, why doesn't "<code>git ls-files -s</code>" return nothing after commit?</p> </blockquote> <p>Because <strong>the index represents what is being tracked</strong>, and right after a commit, what is being tracked is identical to the last commit (<code>git diff --cached</code> returns nothing). </p> <p>So <code>git ls-files -s</code> lists all files tracked (object name, mode bits and stage number in the output).</p> <p>That list (of element tracked) is initialized with the content of a commit.<br> When you switch branch, the index content is reset to the commit referenced by the branch you just switched to.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload