You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
If No Staged Files, Changed Files are Added to Commit #15613
bugIssue identified by VS Code Team member as probable buggitGIT issuesgood first issueIssues identified as good for first-time contributorshelp wantedIssues identified as good community contribution opportunitiesverifiedVerification succeeded
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).
Reacted by CJ Bell, Naoto Ishida, Simon de Lang, Kit Westneat, Adrian C. Shum, Michael Yu, Mike Seese and Dominik K.
I would definitely like a setting to disable that, please.
Reacted by oelshocht, Simon de Lang, Jared Plowman, Adam Petrovic, Adrian C. Shum, Jason Douglas, Matt Dickinson, Viktor Honti, Mike Seese and Vu Quoc Huy
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 CJ Bell (@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.
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:
I have been looking at this and related issues (before I saw you were too Mike Seese (@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.
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.
EDIT: #26169 was closed because it is no longer an issue (I verified your issue using an outdated rebase of master). João Moreno (@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.
bugIssue identified by VS Code Team member as probable buggitGIT issuesgood first issueIssues identified as good for first-time contributorshelp wantedIssues identified as good community contribution opportunitiesverifiedVerification succeeded
Activity
siegebell commentedon Nov 17, 2016
This behavior is likely intentional, but after many revert-last-commit operations, I've come to really hate it.
joaomoreno commentedon Nov 17, 2016
This is intended.
Would you like a setting to disable that?
atolken commentedon Nov 17, 2016
I would definitely like a setting to disable that, please.
maxfie1d commentedon Nov 25, 2016
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.
mikeseese commentedon Mar 31, 2017
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.
mozram commentedon Apr 20, 2017
Any progress on this issue? As CJ Bell (@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.
Mike Seese (@seesemichaelj) suggestion is very good actually.
joaomoreno commentedon Apr 25, 2017
I like the way you're thinking. Let's create a
git.enableSmartCommitsetting, defaults tofalse.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:YesAlwaysCancelAlwayswould change that setting totrue.Anyone cares to submit a PR?
mikeseese commentedon Apr 26, 2017
I'll give this a shot
Edit: I believe the below pull request (#25364) is how this is supposed to be implemented.
ashirley commentedon May 3, 2017
I have been looking at this and related issues (before I saw you were too Mike Seese (@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.
joaomoreno commentedon May 4, 2017
Sorry Andrew Shirley (@ashirley), I've closed your PR. I really liked Mike Seese (@seesemichaelj)'s fix, it's simpler to understand and maintain.
joaomoreno commentedon May 4, 2017
Fixed by #25364
ashirley commentedon May 5, 2017
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.
mikeseese commentedon May 7, 2017
Andrew Shirley (@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). João Moreno (@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.
joaomoreno commentedon May 8, 2017
Good detective work Mike Seese (@seesemichaelj) 😉