Reputation: 6832
In VS Code, the only way that I know of to push commits with git is to go into the "..." menu of the Source Control tab and click Push
.
That method seems a bit roundabout to me, especially considering that there is a unique button to commit code right in the tab. Is there a way to have a push button be next to the commit button in VS Code Source Control?
Upvotes: 77
Views: 55398
Reputation: 4913
Press Ctrl + K + S
to open the shortcut editor.
I spent some time reading the docs to have a really handy shortcut:
The main thing here is the When
condition focusedView == 'workbench.scm'
, this shortcut will only work when you are focusing the source control panel.
So you can quickly write your message, press Ctrl + Enter
to commit (this is by default), then press right away Ctrl + Shift + Enter
to push your commit, without accidentaly pushing your commits when you're editing something else.
Upvotes: 1
Reputation: 1016
VS Code has it there but you have to activate it:
Go to shortcuts by Command/Ctrl + K + Command/Ctrl + S
Then search for "Git Push"
Click on the + that appears when you hover over it
Finally write the keyboard shortcut you want
You can also search for "Git Pull", "Git commit", and even things not related to Git like "kill terminal" or "expand terminal".
Upvotes: 16
Reputation: 7304
There is a new setting Post Commit Command
in vscode 1.30.1 to change the default commit behavior:
Upvotes: 58
Reputation: 19
You can create your own shortcut after doing Ctrl + Shift + P. I have shown it in the pictures below.
Ctrl + Shift + P
You can write "git push" to search.
Then you can write. For example (Ctrl + q).
Upvotes: 1
Reputation: 2451
There is a button at the bottom left of the VS Code editor, which you can click to automatically sync your branch with that from remote (i.e. both pull AND push, merging your branch with upstream if necessary). This might or might not be what you want, but it's easy to click this when you know that there are no changes upstream (e.g. when you're working on a project by yourself).
Otherwise, I frequently bring up the Command Palette with ⇧⌘P (Ctrl-Shift-P on Windows/Linux) and type gpus
, which brings up Git: Push
as the first option. (It's been ingrained in my fingers since the days of Sublime Text)
If you are using the later versions of VS Code which has MRU list of command history, you can shorten it even further and just type gp
, which is exactly what I've been using since SublimeGit
in Sublime Text.
Lastly, another option you may want is to add a custom keyboard shortcut to push changes. You can do this by editing your Keyboard Shortcuts File, and adding something like the following:
{
{
"key": "ctrl+alt+p",
"command": "git.push"
}
}
Upvotes: 103