The book Pro Git says that the staging area is just a list, or index, that says which files will be committed when a git commit
is done, and now the name index
is more commonly known as the "staging area".
But if we modify the file foo.txt
that is already part of the repo, and use git add foo.txt
to stage it, and modify the file again, now the file is both "staged" and "modified" (as seen in git status
), and if we commit, the "staged" version will go into the commit. The second edit won't go in.
So how can the "staging area" keep track of what the first edit was if it is just an index -- a list of files?
git add
actually adds file to the index, as well asgit add
puts the file(s) into staging area (area, where files get before committing). So, are the "index" and "staging area" concepts same or not? I think it's very important to be clear about terminology and the difference (if there is any) between these two terms. – Silvestro