3

Every time I want to commit changes I've made, I have to check the box "Unstaged files" even though I'd previously committed them, and have only modified their contents.

I can't find a setting for this anywhere. Is there one? If not, is there a reason? And/or is there a workaround?

Thanks

StefanS
  • 1,089
  • 1
  • 11
  • 38
Jodes
  • 14,118
  • 26
  • 97
  • 156

2 Answers2

3

The answer to your question is "No. You can't do that."

The reason is that the designers believe a two-stage commit would be useful. While that is true, there is still no reason why they couldn't have a two-stage commit where everything starts out staged unless you unstage it. Looking in from the outside, this looks like a case where the designers believe they understand what is right for a user better than the user does.

William Jockusch
  • 26,513
  • 49
  • 182
  • 323
2

What you're facing is called a two stage commit. This is actually tremendously useful:

https://softwareengineering.stackexchange.com/questions/69178/what-is-the-benefit-of-gits-two-stage-commit-process-staging

  1. Split work into separate commits.

You've probably many times opened a file to write a single-line fix, but at the same time you spotted that the formatting was wrong, some documentation could be improved, or some other unrelated fix. With other RCSes you'd have to write that down or commit it to memory, finish the fix you came for, commit that, and then return to fix the other stuff (or create a ball-of-mud commit with unrelated stuff). With Git you just fix all of it at once, and stage+commit the single line separately, with git add -i or git-gui.

  1. Don't break the build.

You're working on a complicated modification. So you try different things, some of which work better than others, some which break things. With Git you'd stage things when the modification made things better, and checkout (or tweak some more) when the modification didn't work. You won't have to rely on the editor's undo functionality, you can checkout the entire repo instead of just file-by-file, and any file-level mistakes (such as removing a file that has not been committed or saving+closing after a bad modification) does not lead to lots of work lost.

See also:

Community
  • 1
  • 1
FoggyDay
  • 11,962
  • 4
  • 34
  • 48
  • 1
    "useful" is in the eye of the beholder. IMO it would be far more useful to have everything start out staged. I could then unstage if I wanted. YMMV, which is why this sort of thing should be settable. – William Jockusch Feb 28 '16 at 10:04
  • You didn't answer the primary question of whether or not this setting is available. – aaronbauman May 05 '16 at 17:14