3 ms·
> I still don't understand what the point is of having a staging area. Nor do my coworkers who keep committing whitespace changes and machine-specific configu
by Zecc 4y ago
> I still don't understand what the point is of having a staging area.
Nor do my coworkers who keep committing whitespace changes and machine-specific configuration changes unrelated to the tasks at hand.
For a more serious answer: I find it extremely useful to be able to control what goes exactly into each commit. Sometimes I refactor more than one part of the code at the same time. If one part passes tests and another one doesn't, I can commit just the one that does. If I spot an issue in one part of the codebase and I add a TODO or FIXME in a comment, or if add some logging, or some other inconsequential change, I can leave them in the working copy for later while still adding "atomic" changes to the repo.
But by far the most use I get out of it is as a last chance of reviewing the code I just wrote, or as a way of checking the results of an automatic merge before the actual merged commit gets written.
- quanticle 4y agoYou would still be able to do that without a staging area by having `git commit` take roughly the same arguments as `git add`. So instead of running `git add foo bar baz` followed by `git commit`, you'd just write `git commit foo bar baz`, and it'd launch $EDITOR for the commit message. My understanding is that other distributed version control systems, such as Mercurial or Bazaar, take a similar approach to the above.