【发布时间】:2018-11-25 22:45:30
【问题描述】:
我有一个本地 Git 存储库,它有两个遥控器。 origin 是 upstream 的一个分支。我在master 工作。我想实现这个:
-
git pull等价于git pull upstream master -
git push等价于git push origin master -
git pull origin master拉取自origin -
git push upstream master推送到upstream
因此将origin 与upstream 同步的工作流程将简化为
git pull # from upstream
git push # to origin
我已经设法使用一系列git config 命令的以下结果配置第一部分:
[branch "master"]
remote = upstream
merge = refs/heads/master
pushRemote = origin
但是,git push 给了我这个错误:
fatal: You are pushing to remote 'origin', which is not the upstream of
your current branch 'master', without telling me what to push
to update which remote branch.
有什么想法吗?
【问题讨论】:
-
你运行的是什么版本的 Git?您是否更改了
push.default设置?在 Git >= 2.0 中,这应该可以工作,除非您配置了其他一些push.default设置。 -
@torek 我正在使用 Git 2.17,我希望该值在不存在时默认为
simple。但是,在明确指定push.default = simple后,我的问题得到了解决。感谢您的回复。 -
有趣。似乎它应该在没有明确的
push.default设置的情况下工作。不过,我会将其发布为答案。
标签: git git-push git-pull git-remote