吉特.将一个文件的更改合并到同一分支内的另一个文件 [英] Git. Merging changes from one file to another files WITHIN the same branch

查看:20
本文介绍了吉特.将一个文件的更改合并到同一分支内的另一个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个文件:

    master/newsletter1/file.html 
    master/newsletter2/file.html

newsletter1/file.html 有很多我想合并到 newsletter2/file.html 的新更改.我怎样才能做到这一点?我读过的所有内容似乎都解决了分支之间的合并问题,但这些都在同一个分支中:/

newsletter1/file.html has a lot of new changes that I want to merge into 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.
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).

正如 Jefromi 在评论中提到的,以及他在在两个单独的文件上运行 git 合并算法", gitmerge-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.

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

这篇关于吉特.将一个文件的更改合并到同一分支内的另一个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆