git - 文件重命名后如何 merge 两个不同的文件

标签 git

我在分支 master 的 git 存储库中创建了一个文件 foo

然后,我使用 git checkout -b dev 创建一个新分支 dev

在分支 dev 上,我使用 git mv foo bar 将其重命名为 bar

之后,我更改了 foo 中的某些内容并提交。

但是,当我 checkout 分支 devgit merge master 时,git 不会自动为我 merge 它并要求我 merge 我自己。

那么,在我执行git mv之后,foobar的祖先吗?有没有办法让git自动 merge ?

最佳答案

正如“git merge with renamed files”中提到的,您应该尝试调整重命名阈值:

Since git 1.7.4, you can specify the rename threshold for merge as

git merge -X rename-threshold=25 

in order to control that a similarity of 25% is already enough to consider two files rename candidates.
This, depending on the case together with -X ignore-space-change may make rename detection more reliable.

仍然来自Tilman Vogel ,脚本git-merge-associate当 merge 未检测到重命名时,可以帮助恢复两个文件之间的关联(一个是另一个文件的重命名版本)。

关于git - 文件重命名后如何 merge 两个不同的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15447213/

相关文章:

git - 每次提交的成本

git - 持续将docker数据上的elasticsearch推送到S3

git - 使用 Gitlab Ci Cd 将文件添加到存储库

git - "unknown revision or path not in the working tree"尝试获取特定提交到新目录时

linux - 在 nodejs 的部署服务器上初始化 git

git - 如何让 git 维护一个包含选择信息的 git.properties 文件

git - 如何将一个特定文件从一个分支 merge 到 Git 中的另一个分支

git - Git 的@{upstream} 和@{push} 有何不同?

git - 如何在 git 存储库中使用 "artificial root commit"?

git - 显示 SmartGit 中哪些文件已更改