26

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?

2
  • Have you tried git push origin brnach_name ? Commented Jul 13, 2016 at 11:15
  • 3
    At the moment there is no way to do that from VSCode, you need to use the command line. Commented Jul 13, 2016 at 11:21

2 Answers 2

39

Update 2022-12-27

On the Source Control tab (Ctrl++G or ^++G on Mac), press to access Git commands dropdown menu:

  1. Switch to the branch to push – Branch > Create Branch OR Checkout to... > ➕ Create New Branch

    Commit & Push button

  2. Press the Commit & Push button (if not visible, press under the Message text box)

  3. two popups will show up for you to confirm staging, committing and pushing of your changes to this new branch

Confirm & commit unstaged changes Publish and push new branch

Alternative using only menu options:

  1. Switch to the branch to push – Branch > Create Branch OR Checkout to... > ➕ Create New Branch
  2. Stage your changes – button above the files list OR Changes > Stage All Changes (several Git: options available)
  3. Commit your changes – top left button OR Commit
  4. Push the new branch: Branch > Publish Branch (or just use the Push option and press OK in the popup)

All above options can be accessed through commands F1 (Mac: fn+F1 or ++P) and typing git [command], e.g. "git checkout".

For previous versions, check this answer's timeline.

Sign up to request clarification or add additional context in comments.

2 Comments

I don't see how this answers the original question. Where is the option to manually specify remote branch?
@Cavaler pushing directly to a remote branch that is not synced with your local branch is still not possible in 2023-01-30 VS Code without extensions: the workaround is to create locally a branch with the name you want in the remote, switch to it and push it (the previous updates I made also rely on this).
-1

git push an existing project to GitHub git init git add . git commit -m "Add existing project files to Git" git remote add origin https://github.com/cameronmcnz/example-website.git git push -u -f origin master

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.