如何让git默认推送到当前远程?

发布于 2025-01-09 00:20:47 字数 1352 浏览 0 评论 0原文

我有一个存储库,其中一些分支位于公共远程,其他分支位于私有远程:

origin  [email protected]:name/project (fetch)
origin  [email protected]:name/project (push)
private [email protected]:name/project-private (fetch)
private [email protected]:name/project-private (push)

因此,例如分支“some-public-feature”将位于“origin”远程,而“some-private-功能”将位于“私人”遥控器上。

这工作正常并且内容被推送到正确的存储库。但是,当我尝试从私有分支推送时,它总是显示此消息:

fatal: The upstream branch of your current branch does not match
the name of your current branch.  To push to the upstream branch
on the remote, use

    git push private HEAD:some-private-feature

To push to the branch of the same name on the remote, use

    git push private HEAD

所以我真的需要输入 git push private HEAD ,它工作正常,但我想知道是否有任何方法可以使git 默认这样做吗?换句话说,“git push”应该始终将当前分支推送到远程上的同名分支。知道是否可以做到吗?

(请注意,我对于公共分支没有这个问题 - 在这种情况下,简单的“git Push”可以按预期工作,所以我不确定有什么不同)

I've got a repository where some branches are on a public remote, and others on a private remote:

origin  [email protected]:name/project (fetch)
origin  [email protected]:name/project (push)
private [email protected]:name/project-private (fetch)
private [email protected]:name/project-private (push)

So for example a branch "some-public-feature", will be on the "origin" remote, while "some-private-feature" will be on the "private" remote.

This works fine and things get pushed to the correct repositories. However when I try to push from the private branch, it always displays this message:

fatal: The upstream branch of your current branch does not match
the name of your current branch.  To push to the upstream branch
on the remote, use

    git push private HEAD:some-private-feature

To push to the branch of the same name on the remote, use

    git push private HEAD

So really I need to type git push private HEAD, which works fine, but I'm wondering if there's any way to make git do this by default? In other words, "git push" should always push the current branch to the branch of the same name on the remote. Any idea if that can be done?

(Note that I don't have this problem for the public branches - in that case, a simple "git push" works as expected, so I'm not sure what's different)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文