如何在 SourceTree 中自动暂存文件

How to automatically stage files in SourceTree

每次我想提交我所做的更改时,我都必须选中该框 "Unstaged files" 即使我之前提交过它们,并且只修改了它们的内容。

我在任何地方都找不到这方面的设置。有吗?如果没有,有什么原因吗? And/or 有解决办法吗?

谢谢

你面对的是two stage commit。这实际上非常有用:

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.

另请参阅:

你的问题的答案是 "No. You can't do that."

原因是设计者认为两阶段提交会很有用。虽然这是事实,但他们仍然没有理由不能进行两阶段提交,除非您取消暂存,否则所有内容都开始暂存。从外面看,这看起来像是设计师认为他们比用户更了解什么对用户是正确的。