git - Git暂存文件存储在哪里?

标签 git github

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

最佳答案

暂存发生在 .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$ 

关于git - Git暂存文件存储在哪里?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27264809/

相关文章:

git - merge Git 存储库中的两个远程分支

git - 推送 merge 冲突分支

git 扩展名来显式跟踪文件重命名?

docker - 是否可以在具有 Alpine flavor 的 docker 容器中构建 AOSP?

git - 如何找到谁从 GitHub 上的团队项目中删除了功能分支?

git - 超过限制后撤消 git lfs

javascript - chromecast 自定义接收器 - 播放列表在没有 "onLoad"动画的情况下推进媒体

python - 每个项目 flake8 最大行长度?

Github 操作作业超时

ios - Xcode 7 GM 无法验证 git 存储库