Steps to Reproduce:
problem: all files that were changed (even though none were staged) are added to the commit.
expected: if no files are staged, the commit will not add any files (similar to other git tools).
This behavior is likely intentional, but after many revert-last-commit operations, I've come to really hate it.
This is intended.
Would you like a setting to disable that?
I would definitely like a setting to disable that, please.
In the case of Visual Studio, when there are no staged changes, but some changes, the content of the commit button comes "Commit All". So, user can know all changes will be committed even no changes staged.
vscode doesn't have button to commit (use ctrl+Enter instead), and it is difficult to know what happens when commit done.
I would like to add a setting to disable the behavior when no changes staged, or add some ingenuity to let user know what will happen.


Despite the fact that this is easily revertible after an accidental mass commit, the git CLI does not allow you to commit without staged files.
If it's not a setting that disables this functionality, then if there are no staged files, prompt the user that you cannot commit without staged changes and ask if the user would like to stage and commit all changes (with the default option to be No).
Forcing the user to look at the files and intentionally stage them is good practice.
Any progress on this issue? As @siegebell said before, I had to revert commit many times already as I either accidentally pressed CTRL+S or forgot to stage file. I'm hating it now.
@seesemichaelj suggestion is very good actually.
If it's not a setting that disables this functionality, then if there are no staged files, prompt the user that you cannot commit without staged changes and ask if the user would like to stage and commit all changes (with the default option to be No).
I like the way you're thinking. Let's create a git.enableSmartCommit setting, defaults to false.
We can then present the following message, in these cases: There are no staged changes to commit. Would you like to stage all changes and commit them?. The options are:
YesAlwaysCancelAlways would change that setting to true.
Anyone cares to submit a PR?
I'll give this a shot
Edit: I believe the below pull request (#25364) is how this is supposed to be implemented.
I have been looking at this and related issues (before I saw you were too @seesemichaelj , sorry!) and have attempted a solution from a slightly different direction and I have raised PR #25855. I think there is value in trying to merge our two solutions which I will have a look at tomorrow if I can.
Sorry @ashirley, I've closed your PR. I really liked @seesemichaelj's fix, it's simpler to understand and maintain.
Fixed by #25364
No worries. I am a bit concerned that when you press "Always", it changes a file in the directory and then immediately commits it. I wouldn't be expecting this as a user and would want a chance to add the (potentially new) file to .gitignore. Even if I did want to commit this config change, I would want it in a separate commit.
@ashirley I agree and verified what you said. I have opened Issue #26169 to address this
EDIT: #26169 was closed because it is no longer an issue (I verified your issue using an outdated rebase of master). @joaomoreno changed the function to use global settings instead of workspace settings in commit b31c1e1. Therefore, the project's settings.json file will not be created/edited upon clicking Always.
Good detective work @seesemichaelj 馃槈
Most helpful comment
I would definitely like a setting to disable that, please.