美化运行上游后如何合并代码

问题描述

我正在维护一个开源项目的一个分支,为了避免分支过多,我们大约每个月都要从上游拉动一次。

当我本月尝试从上游进行拉取时,我发现它们对整个代码(〜15,000个文件)以及自上次拉取以来我们对fork所做的几乎所有更改进行了美化(或其他等效操作)有很多)导致冲突。

有人遇到过这个问题吗?如果有什么方法可以比手动3种方式合并每个文件更快地进行合并,请提供帮助。

谢谢。

编辑:从我的角度来看,我没有对上游项目的写权限。

解决方法

如果这是您必须使用的工具,那么花费最少的精力(并丢失历史记录)的方式将是:

# checkout the last revision that you merged from upstream _before_ the beautifying process was run in upstream
# run the tool on that revision
git checkout -b the-temp-branch
git commit -m "beautifying base revision"
# now we will create from thing air a revision that has this revision and the tip of the upstream branch as parents,content will be the same as the beautified upstream branch
git commit-tree -p HEAD -p the-upstream-branch -m "merging upstream branch" the-upstream-branch^{tree}
# that command will print an id when you run it... say that ID is XXXX
# set the temp branch over there
git branch -f the-temp-branch XXXX
# go to the tip of your downstream branch
# run the tool
git reset --soft the-temp-branch~
git commit -m "all our changes in a single shot"
# now you can merge the-temp-branch and get all upstream changes... there should not be that many conflics..... move the downstream branch over here when you are done

如果您想重写所有中间的下游修订版本,而不是对所有这些更改进行一次修订,则可以使用相同的概念。这只是更多的工作。

,

没有魔术之路可以解决这个问题。基本上,这些是您分叉和分散时所承担的风险。如果您不喜欢他们在上游所做的事情,请不要合并它,也不要将其合并到与您的工作分支不同的东西中,然后再进行零碎处理。但是,如果要在代码中获取对它们的更改,则只能以某种方式,花些时间解决冲突。

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...