繁体   English   中英

如何为所有初始git push操作设置默认远程

[英]How to set default remote for all initial git push actions

我将我的远程origin设置为从中克隆的存储库,并将me设置为我的fork。 我将push.default设置为current 我想要将默认值push送给me的默认遥控器。 我知道我可以做:

git push -u me

将遥控器永久设置给me (对于当前分支)。 但是,不可避免的是,我第一次忘记这样做。 我想要的是:

git push

将任何分支的远程仓库默认为me 但是文档说:

When the command line does not specify where to push with the <repository> argument, branch.*.remote configuration for the current branch is consulted to determine where to push. If the configuration is missing, it defaults to origin.

我希望它不默认为origin 我已经看过为什么我总是需要做--set-upstream`吗? (和其他),但似乎在这里找不到我的答案。

使用以下命令

git remote set-url --push origin <URL-of-me>

git仍将默认为repo origin ,但是在推送时,它将使用您提供的URL。 提取/提取时,它仍将使用您从中克隆的URL。

但是您可能希望默认情况下推送到测试系统,并在推送到生产服务器时保持明确。 一个更清洁的解决方案:

git clone <production-URL>
cd <project>
git remote set-url origin <test-URL>
git remote add production <production-URL>

在这之后

git push

将推送到测试站点,然后

git push production

将推送到生产站点(原始来源)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM