[英]Git pull with rebase causing excessive conflicts. How can I fix our workflow?
We have a base system that is customized for each client. 我们有一个为每个客户定制的基础系统。 The base lives in its own repository, and each client lives in its own repository (originally cloned from base). 基础存在于自己的存储库中,每个客户端都位于自己的存储库中(最初从基础克隆)。
The goal is to have the ability to add bug fixes/features to base, which can be propagated to clients, on demand. 目标是能够向基础添加错误修复/功能,可以根据需要传播到客户端。
So far the workflow has been as follows: 到目前为止,工作流程如下:
git commit -m "Fix admin typo"
为基本修复/功能制作提交/主题分支:(在基础上,主要) git commit -m "Fix admin typo"
git merge base/master
. 将这些更改合并到客户端:(在客户端,主服务器上) git merge base/master
。 Obviously, this includes fixing any conflicts between base and the client's customizations. 显然,这包括修复base和客户端自定义之间的任何冲突。 git push origin master
将合并推送到客户端的原点:(在客户端,主服务器上) git push origin master
git pull --rebase origin master
那么,在客户端项目上工作的另一个开发人员(在客户端,主人) git pull --rebase origin master
It is at this point that we reach significant problems with that pull/rebase. 正是在这一点上,我们通过拉/ rebase达到了重大问题。 Developers get conflicts in the pull/rebase done after a merge from the base into client. 开发人员在从基础到客户端的合并之后完成了pull / rebase中的冲突。 And its not just a few conflicts, it's many (for many of the commits being replayed?), and often code that particular developer never even touched. 它不仅仅是一些冲突,还有很多(许多提交被重播?),而且通常是特定开发人员从未触及过的代码。 I think this is unreasonable and unsustainable. 我认为这是不合理的,也是不可持续的。
What's the best solution here? 什么是最好的解决方案?
My only thought is to stop using rebase when pulling and deal with sloppy and hard-to-read logs, but I'd rather not have to do this. 我唯一的想法是在拉动和处理草率和难以阅读的日志时停止使用rebase,但我宁愿不必这样做。 These client projects can live on for years, and I'd like to be able to still make some sense out of base system merges in the future. 这些客户端项目可以存在多年,我希望将来能够从基础系统合并中找到一些意义。
Let me get this straight on your repos: 让我直接介绍你的回购:
base
主要项目是独立的,称为base
base
, only pulling updates 每个客户端项目都是从base
克隆的,只是提取更新 client_foo
repo, and push
/ pull
to/from that 开发人员从公共client_foo
repo工作,并push
/ pull
The workflow is failing because one dev is rebasing client_foo
branch onto the new commits from the base
repo and pushing back to client_foo
. 工作流失败,因为一个开发人员将client_foo
分支重新定位到base
client_foo
的新提交并推回到client_foo
。 This will end up breaking all the other devs using client_foo
when they try to do their next pull. 当他们尝试进行下一次拉动时,这将最终使用client_foo
打破所有其他开发人员。 So you can't do that, and expect git to automatically handle it. 所以你不能这样做,并期望git自动处理它。
If it was just one dev per client repo, then maybe that would work. 如果它只是每个客户回购一个开发者,那么也许这将有效。 I'm assume that is not the case. 我认为情况并非如此。
Options: 选项:
Continue doing what your doing, but when the dev pushes the rebased client_foo
branch (with the new base
commits) back to the public client_foo
repo, everyone else has to do a reset --hard
on origin/master
. 继续做你正在做的事情,但是当开发者将重新定位的client_foo
分支(使用新的base
提交)推回到公共client_foo
repo时,其他人都必须reset --hard
在origin/master
上进行reset --hard
。 If they keep all their unpushed changes in a private topic branch then, they have to rebase
those back onto the new client_foo/master
. 如果他们保持在一个私人话题分公司所有的unpushed变化的话,他们必须rebase
的回新client_foo/master
。
Have your dev merge
changes from base
to client_foo
. 让你的dev merge
从base
到client_foo
变化。 This will give you a merge commit on client_foo
which you said you are trying to avoid, but it will give you the most accurate history. 这将给你在client_foo
上的合并提交,你说你试图避免,但它会给你最准确的历史记录。 When your devs do a 'pull --rebase', you should no longer get the long list of conflicts you have now. 当你的开发者做一个“拉动 - 基础”时,你不应该再得到你现在所拥有的长长的冲突列表。
Have your dev cherrypick
the changes from base
onto client_foo
. 有你的开发cherrypick
从变化base
上client_foo
。 This keeps your history linear, but git will no longer track that the cherrypick
'd commits came from base
. 这使你的历史保持线性,但是git将不再跟踪cherrypick
commit来自base
。 You'll have to come up with another way to track it. 你必须想出另一种方法来跟踪它。
I would say stick with #2 since that is the way git is supposed to work. 我会说坚持#2,因为这是git应该工作的方式。 However, someone else may think of a better non-obvious solution. 但是,其他人可能会想到一个更好的非显而易见的解决方案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.