I understand that the typical Git workflow is a three step process: (modify files in work tree) -> (modify the index with git add/rm/etc
) -> (run git commit
).
However, why doesn't Git just treat the work tree as the staging area? E.g., you modify a file and it's automatically "staged" for commit unless you specifically tell git not to stage it. This is more of an "opt-out" approach rather than "opt-in", which makes sense to me because 99% of the files in your work tree will be committed. It would also render the whole git stash
mechanism redundant, as you could simply create a temporary branch from your work tree rather than save
a stash to apply
later on.
If there's a valid reason for the separation between the work tree and the index, I'd love to hear it... perhaps my confusion is stemming from the fact that I haven't fully got my head around Git as yet.
The Git site actually has a good explanation of what the staging area is, the reason why it exists, the benefits it offers, and a way to bypass it when making your commits.
Taken from http://git-scm.com/about/staging-area
Hope this helps. Cheers!