[英]Git. Merging changes from one file to another files WITHIN the same branch
I have two files: 我有两个文件:
master/newsletter1/file.html
master/newsletter2/file.html
newsletter1/file.html has a lot of new changes that I want to merge into newsletter2/file.html. newsletter1 / file.html有很多我想要合并到newsletter2 / file.html的新变化。 How can I achieve this? 我怎样才能做到这一点? Everything I have read seems to resolve around merging between branches, but these are in the same branch :/ 我读过的所有内容似乎都解决了分支之间的合并问题,但这些分支在同一个分支中:/
I would recommend using a third-party diff tool of your choice, in order to do a manual merge between the two files. 我建议使用您选择的第三方diff工具,以便在两个文件之间进行手动合并。
This is not about source-control (ie managing the history of versions for one file). 这与源控制无关(即管理一个文件的版本历史)。
This is about reporting changes from one files to another (the source-control tool will then pick up the new version for the second file). 这是关于报告从一个文件到另一个文件的更改(源控制工具将为第二个文件选择新版本)。
As Jefromi mentions in the comments, and as he explains in " run git merge algorithm on two individual files ", git merge-file
can actually merge two different files, provided a common ancestor is provided. 正如Jefromi在评论中提到的,正如他在“ 对两个单独文件运行git merge算法 ”中所解释的那样, git merge-file
实际上可以合并两个不同的文件,前提是提供了一个共同的祖先。
git merge-file <current-version> <common-ancestor> <other-version>
In your case, you could try with the common ancestor being identical to the current file. 在您的情况下,您可以尝试使用与当前文件相同的共同祖先。
git merge-file master/newsletter2/file.html master/newsletter1/file.html master/newsletter2/file.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.