I personally prefer to use the same keyboard shortcut for both "Stage Changes" and "Unstage Changes".
If I set the same keyboard shortcut for both, only one of them (namely, "Stage Changes") is enabled.
(Experimental duplicate detection)
Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:
@birgersp How did you configure those keybindings? Can you show me your keybindings.json?
@joaomoreno Thanks for getting back to me so quickly! I configured the keybindings by opening the keybindings editor with "File"->"Preferences"->"Keyboard Shortcuts".
Then I double-clicked the "Stage Changes" command, and pressed CTRL+T followed by ENTER to assign it. Did the same for "Unstage Changes".
My keybindings.json file looks like this:
// Place your key bindings in this file to overwrite the defaults
[
{
"key": "ctrl+t",
"command": "git.stage"
},
{
"key": "ctrl+u",
"command": "git.unstage"
}
]
Got it. What would your prefer to happen if the file is both staged and modified in the working tree?
I am thinking wheter it should be staged or unstaged depends on the current selection. Meaning;
When the command is invoked, and
For instance, pressing the keyboard shortcut here, would cause the file to be unstaged (since it is selected as a staged file):

Notice that the command doesn't know about selection, only about the currently opened file. There's no current API to get a hold of that selection.
Understood. Personally, I don't have any opinion as to what should happen if the file is both staged and unstaged.
I suggest we just stage it.
I actually wanted to see whether there are hidden when clauses we could be used to detect which mode we are in, and set keybindings accordingly... Something like:
[
{
"key": "ctrl+t",
"command": "git.stage",
"when": "inDiffEditor" // only for illustrative purposes, i don't know if there is a when clause for this mode
},
{
"key": "ctrl+t",
"command": "git.unstage",
"when": "inDiffEditor && inStagedView" // only for illustrative purposes, i don't know if there is a when clause for this mode
}
]
I actually wanted to see whether there are hidden when clauses we could be used to detect which mode we are in, and set keybindings accordingly
@kumarharsh: Found anything about that when clause?
Nopes ☹. The core team needs to answer this.
@kumarharsh Maybe try something like resourceScheme == git.
This issue is being closed to keep the number of issues in our inbox on a manageable level, we are closing issues that are not going to be addressed in the foreseeable future: We look at the number of votes the issue has received and the number of duplicate issues filed. More details here. If you disagree and feel that this issue is crucial: We are happy to listen and to reconsider.
If you wonder what we are up to, please see our roadmap and issue reporting guidelines.
Thanks for your understanding and happy coding!
Most helpful comment
I actually wanted to see whether there are hidden
whenclauses we could be used to detect which mode we are in, and set keybindings accordingly... Something like: