设置默认推送目标

时间:2019-04-11 12:13:47

标签: git visual-studio-code

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

2 个答案:

答案 0 :(得分:0)

不确定是否在VSC内,但可以从命令行输入。 git push -u <remoteName> <branchName>。远程可以是GitHub或Azure。

答案 1 :(得分: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>.remote的部分(由remote.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