大文件移动后合并功能分支
Merging a feature branch after a big file move
一开始,我的仓库是这样的:
master:
foo/
bar/
new-bar/
在功能分支中,许多提交已添加到新栏:
feature:
foo/
bar/
-/
并且在 master 分支中,删除了 bar 并将 new-bar 移到了它的位置 git mv
:
master:
foo/
b̶a̶r̶/
bar/
我想在不引起大量冲突的情况下合并功能分支:
master:
foo/
b̶a̶r̶/
/
我该如何完成?
如果您选择在 master
之上重新设置您的功能分支,重命名应该会进行得相当顺利。受审。完成变基后,您的分支应该和以前一样,除了所有更改都将在 bar/
而不是 new-bar/
.
中完成
如果您决定不对其进行变基,我会在您的功能分支的顶部添加一个提交,将 new-bar/
移动为 bar/
,以便它与 master
兼容,然后合并它。
无论如何你都必须尝试看看什么更适合你的需要。
- Rename detection logic that is used in "merge" and "cherry-pick" has
learned to guess when all of x/a, x/b and x/c have moved to z/a,
z/b and z/c, it is likely that x/d added in the meantime would also
want to move to z/d by taking the hint that the entire directory
'x' moved to 'z'.
AFAICT 这涵盖了您的用例——只需使用现代 Git 版本。
一开始,我的仓库是这样的:
master:
foo/
bar/
new-bar/
在功能分支中,许多提交已添加到新栏:
feature:
foo/
bar/
-/
并且在 master 分支中,删除了 bar 并将 new-bar 移到了它的位置 git mv
:
master:
foo/
b̶a̶r̶/
bar/
我想在不引起大量冲突的情况下合并功能分支:
master:
foo/
b̶a̶r̶/
/
我该如何完成?
如果您选择在 master
之上重新设置您的功能分支,重命名应该会进行得相当顺利。受审。完成变基后,您的分支应该和以前一样,除了所有更改都将在 bar/
而不是 new-bar/
.
如果您决定不对其进行变基,我会在您的功能分支的顶部添加一个提交,将 new-bar/
移动为 bar/
,以便它与 master
兼容,然后合并它。
无论如何你都必须尝试看看什么更适合你的需要。
- Rename detection logic that is used in "merge" and "cherry-pick" has learned to guess when all of x/a, x/b and x/c have moved to z/a, z/b and z/c, it is likely that x/d added in the meantime would also want to move to z/d by taking the hint that the entire directory 'x' moved to 'z'.
AFAICT 这涵盖了您的用例——只需使用现代 Git 版本。