【发布时间】:2019-09-02 01:47:27
【问题描述】:
如何在 Visual Studio Code 中设置推送的默认目标?我目前配置了两个目标(github 和 azure),并希望将菜单中的“推送”操作设置为两者之一。
【问题讨论】:
如何在 Visual Studio Code 中设置推送的默认目标?我目前配置了两个目标(github 和 azure),并希望将菜单中的“推送”操作设置为两者之一。
【问题讨论】:
我会尝试在您的项目配置中设置默认遥控器。也许,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。
【讨论】:
在 VSC 中不确定,但在命令行中。 git push -u <remoteName> <branchName>。 Remote 可以是 GitHub 或 azure。
【讨论】: