【问题标题】:Set default push target设置默认推送目标
【发布时间】:2019-09-02 01:47:27
【问题描述】:

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

【问题讨论】:

标签: git visual-studio-code


【解决方案1】:

我会尝试在您的项目配置中设置默认遥控器。也许,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.&lt;name&gt;.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

【讨论】:

    【解决方案2】:

    在 VSC 中不确定,但在命令行中。 git push -u &lt;remoteName&gt; &lt;branchName&gt;。 Remote 可以是 GitHub 或 azure。

    【讨论】:

    • 知道了,但主要是如何告诉 VSC 哪个目标应该是我的默认远程目标。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-21
    • 2016-04-25
    • 2013-05-25
    • 2010-11-24
    • 2018-09-02
    相关资源
    最近更新 更多