Git Internals
Staging

Differences between GitRepoAfterStaging1 and EmptyGitRepo1
Figure 1: Differences between GitRepoAfterStaging1 and EmptyGitRepo1

The state of the staging area is held in the .git/index file (index was the original name for the staging area and the term is still widely used). The format of the index file is described in git/Documentation/technical/index-format.txt [1].

The contents of the index file after the "HelloWorld.txt" file was added to it is shown in Figure 2.

Contents of the index file
Figure 2: Contents of the index file
SectionOffsetLengthValueDescription
Header0444 49 52 43Signature of the index file. All index files start with this signature.
4400 00 00 02Version of the index, 2 in this example.
8400 00 00 01Number of entries in the index, 1 in this example.
Entry12455 57 44 7932-bit ctime seconds, the last time a file's metadata changed
16400 00 00 0032-bit ctime nanosecond fractions
20455 57 44 7932-bit mtime seconds, the last time a file's data changed
24400 00 00 0032-bit mtime nanosecond fractions
28400 00 00 0032-bit dev
32400 00 00 0032-bit ino
36400 00 81 A432-bit mode
40400 00 00 0032-bit uid
44400 00 00 0032-bit uid
48400 00 00 0D32-bit file size, 13 bytes in this case.
522098 0A 0D 5F 19 A6 4B 4B 30 A8 7D 42 06 AA DE 58 72 6B 60 E3160-bit SHA-1 for the represented object
72200 0E
741848 65 6C 6C 6F 57 6F 72 6C 64 2E 74 78 74 00 00 00 00
Signature922087 AD 90 A2 7C AB 3F F5 42 5F F7 44 91 A8 F0 35 FC E8 78 AA160-bit SHA-1 over the content of the index file before this checksum.

Contents of the object adding during staging

Xavier Leclercq@PATHFINDER /c/GitInternalsExampleRepos/GitRepoAfterStaging1 (mas
ter)
$ git cat-file -t 980a0d5f19a64b4b30a87d4206aade58726b60e3
blob

Xavier Leclercq@PATHFINDER /c/GitInternalsExampleRepos/GitRepoAfterStaging1 (mas
ter)
$ git cat-file -s 980a0d5f19a64b4b30a87d4206aade58726b60e3
13

Xavier Leclercq@PATHFINDER /c/GitInternalsExampleRepos/GitRepoAfterStaging1 (mas
ter)
$ git cat-file -p 980a0d5f19a64b4b30a87d4206aade58726b60e3
Hello World!

Xavier Leclercq@PATHFINDER /c/GitInternalsExampleRepos/GitRepoAfterStaging1 (mas
ter)
$

References

  1. git/Documentation/technical/index-format.txt

Further Reading

  1. Stackoverflow: What does the git index contain EXACTLY?

blog comments powered by Disqus

Copyright(c) 2006-2017 Xavier Leclercq | Privacy policy

Home
Contact Us
Search