I realized that after a commit in VSCode there's a "Push" menu option that pushes the commit to the default branch.
However, I often need to push it as well to different branches. Is there a way to do this or run git push --progress "origin" DEFAULT_BRANCH:OTHER_BRANCH
through VSCode?
To push a local branch to the remote, right click on that branch in Team Explorer. From the context menu, that pops up on the screen, select Push Branch.
Push Branch to Another Branch In some cases, you may want to push your changes to another branch on the remote repository. In order to push your branch to another remote branch, use the “git push” command and specify the remote name, the name of your local branch as the name of the remote branch.
To force a push to only one branch, use a + in front of the refspec to push (e.g git push origin +master to force a push to the master branch). See the <refspec>... section above for details.
Just enter your commit message and then select Commit All. The equivalent command for this action is git commit -a . Visual Studio also makes it easy to commit and sync with one click by using the Commit All and Push and Commit All and Sync shortcuts.
On the Source Control tab (Ctrl+Shift+G), press ⃛ to access Git commands dropdown menu, or simply use F1 and type the Git command:
Push command is now for branches already pushed to remote.
VS Code now has a specific option to allow a Push to... a specific remote (not a branch) through the ... (hover the repo in the source control tab Ctrl+Shift+G) OR through F1+type push to.
TLDR; (re-answering the question)
After all it's possible, this is a non direct way of pushing into another branch with VSCode, so answering my own question:
You can later switch back to your initial branch with F1+Git Branch+ENTER+[branch name]+ENTER. The only problem with this is that VSCode does not allow you to push again those same changes back to the initial branch (even with F1+Git Push).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With