git:如何指定默认的远程推送到分支?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3599412/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 04:32:31  来源:igfitidea点击:

git : how to specify a default remote push-to branch?

gitgit-pushremote-branch

提问by Shawn

Suppose I have a tracking branch named 'abc' which tracks origin/master.

假设我有一个名为 ' abc'的跟踪分支,它跟踪origin/master.

When I'm on 'abc' and do a git push, it pushes 'abc' to 'abc'.
How do I specify the remote push branch for it with just a 'git push'?

当我在 ' abc' 上执行 a 时git push,它会将 ' abc'推到 ' abc'。
如何仅使用“ git push”为其指定远程推送分支?

回答by VonC

git branch --set-upstream-to abc origin/master

should be able to specify the remote branch.

应该能够指定远程分支。

Note the -toadded to --set-upstreamsince git1.8.0.

请注意-to添加到--set-upstream自 git1.8.0

Since Git1.7.0:

Git1.7.0 开始

"git branch --set-upstream" can be used to update the (surprise!) upstream, i.e. where the branch is supposed to pulland mergefrom (or rebase onto).

git branch --set-upstream”可被用于更新(惊喜!)上游,即,其中所述分支是应该pullmerge从(或rebase onto)。

回答by Sridhar Sarnobat

"git push" without a remote branch explicitly named will attempt to push to the site named "origin"

没有明确命名的远程分支的“git push”将尝试推送到名为“origin”的站点