如何在Visual Studio代码中设置推送的默认目标?我目前配置了两个目标(github和azure),并希望将菜单中的“推送”操作设置为两个中的一个。
在VSC中不确定,但从命令行。 git push -u <remoteName> <branchName>
。远程可能是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
。