哪里存储Git阶段文件?

时间:2014-12-03 06:07:29

标签: git github

我不确定但是这个问题在我的脑海中突然出现并开始谷歌搜索。我发现了许多有关暂存的详细信息,但未能找到git放置staged文件的确切位置。我的意思是有一个文件或文件夹,git用来缓存对分阶段文件和文件夹的引用?是的是哪个文件?

1 个答案:

答案 0 :(得分:6)

分段发生在.git/index.git/objects内。前者包含路径,后者包含文件内容。虽然这些都是二进制的。

~/projects/bae/.git$ tree .
.
├── HEAD
├── config
├── description
├── hooks
│   ├── applypatch-msg.sample
│   ├── commit-msg.sample
│   ├── post-update.sample
│   ├── pre-applypatch.sample
│   ├── pre-commit.sample
│   ├── pre-push.sample
│   ├── pre-rebase.sample
│   ├── prepare-commit-msg.sample
│   └── update.sample
├── info
│   └── exclude
├── objects
│   ├── info
│   └── pack
└── refs
    ├── heads
    └── tags

8 directories, 13 files
~/projects/bae/.git$ cd ..
~/projects/bae$ touch test
~/projects/bae$ git add test 
~/projects/bae$ cd .git
~/projects/bae/.git$ tree
.
├── HEAD
├── config
├── description
├── hooks
│   ├── applypatch-msg.sample
│   ├── commit-msg.sample
│   ├── post-update.sample
│   ├── pre-applypatch.sample
│   ├── pre-commit.sample
│   ├── pre-push.sample
│   ├── pre-rebase.sample
│   ├── prepare-commit-msg.sample
│   └── update.sample
├── index                                           <-- NEW (contains paths)
├── info
│   └── exclude
├── objects
│   ├── e6
│   │   └── 9de29bb2d1d6434b8b29ae775ad8c2e48c5391  <-- NEW (contains file content)
│   ├── info
│   └── pack
└── refs
    ├── heads
    └── tags

9 directories, 15 files
~/projects/bae/.git$