考虑这个测试脚本。
#!/bin/sh -x
rm -rf test
git init test
cd test
for I in {1..100}; do
echo $I >> x
done
git add x
git commit -am "initial commit"
git checkout -b branch
git mv x y
git commit -am "renamed"
rm y
for I in {1..60}; do
echo branch$I >> y
done
for I in {61..100}; do
echo $I >> y
done
git commit -am "changed the first 60 lines in branch"
git checkout master
rm x
for I in {1..60}; do
echo master$I >> x
done
for I in {61..100}; do
echo $I >> x
done
git commit -am "changed the first 60 lines in master"
git merge -s recursive -X patience branch
git status
我想让git检测在分支中x
被重命名为y
的名称,并为我提供解决合并冲突的机会。
相反,发生的事情是git忽略(无法检测到)重命名,并说x
在y
创建新的不相关文件时已在分支中将其删除。如何说服git将其作为重命名文件处理?
谢谢!
您是正确的:git进行了重命名检测,而不是重命名跟踪,并且如果文件已更改为“太多”(对于“ too too”的某个值),则git声明此文件为其他文件,而不是重命名文件。
没有完美的解决方案。如果您的git足够新(1.7.4或更高版本),通常最好的选择是将-X rename-threshold=<n>
标志传递给git merge
。降低阈值会使git检测更多的重命名(并且您可以git diff -M
用来测试适当的阈值)。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句