Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set default push target

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.

like image 326
FernSeher Avatar asked Sep 14 '25 06:09

FernSeher


1 Answers

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.

like image 71
padawin Avatar answered Sep 15 '25 19:09

padawin