"Staging area" is convenience jargon for the most common and popular way to use the index. Your first option,
Does it create the blob object and tree object when we do git add and when we do git commit the commit object is linked to the parent commit and corresponding tree object which is already linked to it’s blob/tree object?
has it almost exactly right: git add
puts what you added in the repo, and git commit
ties the commit object to the parent commit and the corresponding tree object - - - but that corresponding tree object isn't in the repo yet, git commit
builds the tree (that ties pathnames to content) by consulting the index, which is exactly what it says it is: an index, tying pathnames to content.
So, git checkout
updates the index to point to the content it checked out at each checked-out path, and git add
updates the index to point to the content it added for each added path.
So you can use this as a "staging area", git commit
only cares what you've added, not what's in your worktree. This is why git checkout
, git reset
, git commit
and git add
all have --patch
options: there's what you checked out, what you've added, and what's in your worktree. At any point it might be useful to see differences between any of those, or "take back" part of the changes you made, maybe because they belong in another commit or just need further work.