4

How can I set the default target for a push in Visual Studio Code? I currently have two targets configured (github and azure) and want to set the "Push" action from the menu to one of the two.

FernSeher
  • 177
  • 1
  • 13
  • 1
    Possible duplicate of [Changing the Git remote 'push to' default](https://stackoverflow.com/questions/18801147/changing-the-git-remote-push-to-default) – Shayki Abramczyk Apr 11 '19 at 12:55

2 Answers2

2

I'd try to set the default remote in your project's configuration. Perhaps, VSC uses it to know where to push?

You can do it as follow:

git config remote.pushDefault nameOfYourRemote

And from man git-config:

remote.pushDefault
       The remote to push to by default. Overrides branch.<name>.remote for all branches, and is overridden by branch.<name>.pushRemote for specific
       branches.

And the section about branch.<name>.remote (that remote.pushDefault overrides):

   branch.<name>.remote
       When on branch <name>, it tells git fetch and git push which remote to fetch from/push to. The remote to push to may be overridden with
       remote.pushDefault (for all branches). The remote to push to, for the current branch, may be further overridden by branch.<name>.pushRemote. If
       no remote is configured, or if you are not on any branch, it defaults to origin for fetching and remote.pushDefault for pushing. Additionally,
       .  (a period) is the current local repository (a dot-repository), see branch.<name>.merge's final note below.

Which allows you to have origin still, but also other remotes and one of them being the default one instead of origin.

padawin
  • 4,230
  • 15
  • 19
0

Not sure within VSC but from the command line. git push -u <remoteName> <branchName>. Remote would either be GitHub or azure.

EncryptedWatermelon
  • 4,788
  • 1
  • 12
  • 28