簡體   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