简体   繁体   English

Git的。 将更改从一个文件合并到同一分支中的另一个文件

[英]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.

相关问题 仅将某些更改从一个git分支合并到另一个 - Merging only certain changes from one git branch to another Git - 在开发人员之间将一个功能分支的更改合并到另一个功能分支 - Git - Merging changes from one feature branch into another between developers 将文件集的最新更改从一个分支合并到另一个分支 - Merging latest changes to sets of files from one branch to another Git:如何将一个文件从分支 A 的更改应用到同一 repo 的分支 B 中的另一个文件? - Git: How to apply changes of one file from branch A to another file in branch B of the same repo? Git钩子-如何将文件从一个文件夹复制到同一git分支内的另一个文件夹 - Git hooks - How to copy files from one folder to another folder within same git branch git:将子树从一个分支合并到另一个分支 - git: merging a subtree from one branch to another 如何将更改从一个功能分支复制到从 GIT 中的同一父分支派生的另一个功能分支 - How to copy changes from one feature branch to another feature branch derived from same parent branch in GIT 使用其他提交将修改后的文件从一个分支合并到另一个分支 - Merging a modified file from one branch, to another branch with additional commits Git Git在一个分支中制作文件与另一个相同 - Git making files in one branch same as another 吉特 如何在错误的分支中保存更改 - Git. How to save changes in wrong branch
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM