源分支落后于目标分支 n 次提交
Source branch behind target branch by n commits
在我的项目中,master
分支包含发布状态,development
分支是完成开发的地方。
项目最初是从SVN导入到master分支,然后创建了develop分支。该项目是使用开发分支进行的。
过段时间想和master合并development但是冲突了。 (我想我可能无意中在 master 分支中添加了一个 CHANGELOG
文件) Github 显示了类似 The source branch is 1 commits behind the target branch
的消息。无论如何,我决定将 master 合并回开发分支,似乎 可以解决问题。我能够将开发分支与主分支合并。
不久之后,我想第二次合并开发到master,得到了类似的消息The source branch is 2 commits behind the target branch
。这似乎表明我之前的操作并没有解决问题。
为什么我的开发分支在主分支后面?我该怎么办
让它们恢复同步?
图表看起来像这样
我显然在这里做错了什么,但我不明白它可能是什么。
图表看起来很奇怪:在行 Merge branch 'development' into 'master'
中,紫色分支被合并到 master 中。但是红色的分支是标记为development
的分支。看起来其他一些开发分支已合并到 master 中。
消息The source branch is 2 commits behind the target branch
表示有两个提交可以从目标(master
)分支到达,但不能从源分支(development
)到达。我猜这些是 First prod release
和 Merge branch 'development' into 'master'
提交,但我们需要查看更多您的存储库历史才能确定。
不建议合并master分支到develop分支
如果你想让你的开发分支与主分支一起更新,你应该使用git rebase
。
A---B---C development
/
D---E---F---G master
在你运行以下命令之一之后:
git rebase master
git rebase master development
您的提交历史将是:
A'--B'--C' development
/
D---E---F---G master
在我的项目中,master
分支包含发布状态,development
分支是完成开发的地方。
项目最初是从SVN导入到master分支,然后创建了develop分支。该项目是使用开发分支进行的。
过段时间想和master合并development但是冲突了。 (我想我可能无意中在 master 分支中添加了一个 CHANGELOG
文件) Github 显示了类似 The source branch is 1 commits behind the target branch
的消息。无论如何,我决定将 master 合并回开发分支,似乎 可以解决问题。我能够将开发分支与主分支合并。
不久之后,我想第二次合并开发到master,得到了类似的消息The source branch is 2 commits behind the target branch
。这似乎表明我之前的操作并没有解决问题。
为什么我的开发分支在主分支后面?我该怎么办 让它们恢复同步?
图表看起来像这样
我显然在这里做错了什么,但我不明白它可能是什么。
图表看起来很奇怪:在行 Merge branch 'development' into 'master'
中,紫色分支被合并到 master 中。但是红色的分支是标记为development
的分支。看起来其他一些开发分支已合并到 master 中。
消息The source branch is 2 commits behind the target branch
表示有两个提交可以从目标(master
)分支到达,但不能从源分支(development
)到达。我猜这些是 First prod release
和 Merge branch 'development' into 'master'
提交,但我们需要查看更多您的存储库历史才能确定。
不建议合并master分支到develop分支
如果你想让你的开发分支与主分支一起更新,你应该使用git rebase
。
A---B---C development
/
D---E---F---G master
在你运行以下命令之一之后:
git rebase master
git rebase master development
您的提交历史将是:
A'--B'--C' development
/
D---E---F---G master