设置默认推送目标

问题描述 投票:2回答:2

如何在Visual Studio代码中设置推送的默认目标?我目前配置了两个目标(github和azure),并希望将菜单中的“推送”操作设置为两个中的一个。

git visual-studio-code
2个回答
0
投票

在VSC中不确定,但从命令行。 git push -u <remoteName> <branchName>。远程可能是GitHub或azure。


0
投票

我尝试在项目配置中设置默认远程。或许,VSC使用它来知道推送的位置?

你可以这样做:

git config remote.pushDefault nameOfYourRemote

来自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.

关于branch.<name>.remoteremote.pushDefault覆盖)的部分:

   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.

这允许你仍然有origin,但也有其他遥控器,其中一个是默认的而不是origin

© www.soinside.com 2019 - 2024. All rights reserved.