While reading how to use Git, I found a lot of different names for git index
.
They were:
directory cache
current directory cache
staging files
staging area
How come there are so many options to name exactly one thing?
How I should to name it to not to confuse my future interlocutors whose backgrounds I do not know?
Git index is a binary file (generally kept in . git/index ) containing a sorted list of path names, each with permissions and the SHA1 of a blob object; git ls-files can show you the contents of the index. Please note that words index , stage , and cache are the same thing in Git: they are used interchangeably.
Git Index may be defined as the staging area between the workspace and the repository. The major use of Git Index is to set up and combine all changes together before you commit them to your local repository.
The easiest way to see what is in the index is with the git status command. When you run git status, you can see which files are staged (currently in your index), which are modified but not yet staged, and which are completely untracked.
These files are also referred to as "untracked files." Staging area is files that are going to be a part of the next commit, which lets git know what changes in the file are going to occur for the next commit. The repository contains all of a project's commits.
I agree with @Harmelodic ... the term "Staging area" is probably most used and straight-forward.
For example, when using the git-add
command, you can say that you are "staging" content.
The term index
was used early on in Git's development but it was changed.
This is a good historical thread.
Snippits:
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
With Git 2.30.1 (Q1 2021), the documentation is now clearer regarding "index" synonyms based on "cache
": they are obsolete and purged from said documentation.
See commit b356d23 (08 Jan 2021) by Utku Gultopu (ugultopu
).
(Merged by Junio C Hamano -- gitster
-- in commit eecc5f0, 15 Jan 2021)
doc
: remove "directory cache" from man pagesSigned-off-by: Utku Gultopu
"directory cache" (or "directory cache index", "cache") are obsolete terms which have been superseded by "index".
Keeping them in the documentation may be a source of confusion.
This commit replaces them with the current term, "index", on man pages.
git ls-files
now includes in its man page:
This merges the file listing in the index with the actual working directory list, and shows different combinations of the two.
git update-index
now includes in its man page:
Modifies the index.
Each file mentioned is updated into the index and any 'unmerged' or 'needs updating' state is cleared.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With