【问题标题】:Unable to merge fork of repository无法合并存储库的分支
【发布时间】:2013-07-11 13:11:57
【问题描述】:

在 GitHub 上有一个我关注的项目(上游):

https://github.com/adaptivecomputing/torque

我有这个 repo 的一个分支(来源):

https://github.com/spudstud/torque

新分支已添加到我想要拉入源的上游存储库,然后添加到我的本地计算机。

根据 GitHub 帮助,这应该很容易。我应该能够使用以下命令同步我的 fork。 https://help.github.com/articles/syncing-a-fork

git fetch upstream
git merge upstream/master

不幸的是,我想要的上游分支(4.2.3、4.2.3.1、4.2.3.h2、4.2.3.h3)仍然没有出现在 origin

git clone git@github.com:spudstud/torque.git
cd torque/
git remote add upstream https://github.com/adaptivecomputing/torque.git
git remote -v
      origin    git@github.com:spudstud/torque.git (fetch)
      origin    git@github.com:spudstud/torque.git (push)
      upstream    https://github.com/adaptivecomputing/torque.git (fetch)
      upstream    https://github.com/adaptivecomputing/torque.git (push)
git fetch upstream
git checkout master
git merge upstream/master

git branch -a
* master
  remotes/origin/2.5-dev
  remotes/origin/2.5.12
  remotes/origin/4.1-dev
  remotes/origin/4.1.0
  remotes/origin/4.1.4
  remotes/origin/4.1.4-1648
  remotes/origin/4.1.5
  remotes/origin/4.1.5.1
  remotes/origin/4.1.5.2
  remotes/origin/4.2.0
  remotes/origin/4.2.1
  remotes/origin/4.2.2
  **** 4.2.3,  4.2.3.1,  4.2.3.h2,  4.2.3.h3 should show up about here^ ****
  ...
  remotes/origin/HEAD -> origin/master
  remotes/origin/master
  remotes/upstream/2.5-dev
  remotes/upstream/2.5.12
  remotes/upstream/4.1-dev
  remotes/upstream/4.1.0
  remotes/upstream/4.1.4
  remotes/upstream/4.1.4-1648
  remotes/upstream/4.1.5
  remotes/upstream/4.1.5.1
  remotes/upstream/4.1.6
  remotes/upstream/4.1.6.h1
  remotes/upstream/4.1.6.h2
  remotes/upstream/4.2-dev
  remotes/upstream/4.2.0
  remotes/upstream/4.2.1
  remotes/upstream/4.2.2
  remotes/upstream/4.2.2.ufl
  remotes/upstream/4.2.3
  remotes/upstream/4.2.3.1
  remotes/upstream/4.2.3.h2
  remotes/upstream/4.2.3.h3
  remotes/upstream/master

到目前为止,我所读到的任何内容都无法解释问题可能是什么:

解决方案 感谢答案,我想通了。 我不明白我需要将更改推回分支:​​

git push origin 4.2.4

看来我试图做的是“快进”我的叉子。 GitHub 曾经有一个快进按钮,可以自动使您的分叉存储库与上游同步,Fast Forward Your Fork。看起来 GitHub 摆脱了快进功能(据我所知),所以我必须对每个分支重复这些步骤。

【问题讨论】:

  • +1 做你的功课。我会给你另一个 +1 以添加指向 Git 存储库的链接,但我只能投票一次;)

标签: git github


【解决方案1】:

origin你的 叉子。上游repo叫upstream,存在upstream/4.2.3等。您可以使用$ git push origin upstream/4.2.3 等将它们推送到您的存储库。这两个存储库不会自动同步。

【讨论】:

  • 理论上这听起来不错。我已经尝试了两次,但仍然没有在原点gist.github.com/spudstud/5988534看到4.2.3@
  • @spuder:你推送后获取origin了吗?
  • (当然,我认为您不必这样做;不过我记不清了。)
【解决方案2】:

您只是在合并 master 分支。如果您想关注上游分支(我认为这就是您想要的,内联注释似乎正在寻找 4.2.3 等),那么您需要在本地跟踪它们(假设您希望更改可用于阅读/编辑) 然后将它们推回您的 fork。

git checkout -t upstream/4.2.3

然后将它们推回你的叉子

git push origin 4.2.3

所有 fetch 所做的只是拉动整个遥控器。当您git merge 时,您的版本只是将上游/主服务器与您的local/master 合并。

【讨论】:

  • 谢谢,虽然这在理论上可以解决问题,但这并不理想,因为我每次提交时都必须记住推送到我的原点。如果我对上游和源都有写访问权,我可以很容易地推送到错误的仓库。
  • 您必须指定是否要推送到原点以外的其他地方。如果您对上游有写访问权,那么推送到那里的唯一方法(如果您从叉子克隆)是 git push upstream .
  • 如果你真的很想只去远程,使用强制标志。从上游获取后, git push -f origin 4.2.3
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-07-08
  • 2016-05-31
  • 1970-01-01
  • 1970-01-01
  • 2018-11-14
相关资源
最近更新 更多