gpt4 book ai didi

git - 为什么 "git index"有这么多名字?

转载 作者:太空狗 更新时间:2023-10-29 13:35:09 25 4
gpt4 key购买 nike

在阅读如何使用 Git 时,我发现 git index 有很多不同的名称。

他们是:

  • 目录缓存
  • 当前目录缓存
  • 暂存文件
  • 暂存区

为什么有这么多选项可以准确命名一件事?

我应该如何命名它才不会混淆我 future 的背景我不知道的对话者?

最佳答案

我同意@Harmelodic 的观点……“暂存区”这个词可能是最常用和最直接的。

例如,当使用 git-add 命令时,您可以说您正在“暂存”内容。

术语 index 在 Git 的开发早期使用过,但后来发生了变化。

This是一个很好的历史线索。

片段:

Commands that pay attention to the registered content of files rather than the copies in the work tree use the option name "--cached". This is mostly for historical reasons --- early on, it was not obvious that making the index not match the worktree was going to be useful.

...

"cache" was an old name (and still established name in-use in the code) for the index...cached to mean "look only at what is recorded in the index".

...

Originally, the way to say "what is in the current working tree for this path is what I want to have in the next commit" was "update-index". "What I want to have in the next commit" is "the index", and the operation is about "updating" that "What I want to have...", so the name of the command made perfect sense. "update-index" had a safety valve to prevent careless invocation of "update-index *" to add all the cruft in the working tree (there wasn't any .gitignore mechanism in the Porcelain nor in the plumbing) and by default affected only the paths that are already in the index. You needed to say "update-index --add" to include paths that are not in the index.

A more user friendly Porcelain "git add" was later implemented in terms of "update-index --add", but originally it was to add new paths; updating the contents was still done via "update-index" interface.

...

In short, "stage" is an unessential synonym that came much later

关于git - 为什么 "git index"有这么多名字?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36087017/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com