问题描述
我想在2个分支之间比较文件,并仅对特定作者的比较应用补丁(类似于git blame diff?)。我需要对许多文件执行此操作。
基本上,在IntelliJ上,当我尝试解决其合并工具窗口中的冲突时,我可以选择annotate
来显示每行的作者,为此我可以手动应用不冲突和冲突的行从另一个分支更改作者。我想以编程方式执行此操作。
git log branch1..branch2 --author '\(author1\|author2)' --reverse --pretty=%H $file
然后
git cherry-pick -n --strategy=recursive -n $commit -X theirs
然而,-X theirs
仅在发生冲突的情况下才选择来自另一个分支的提交。我也打算从其他分支机构中选择无冲突的差异,但仅针对特定作者。
我该如何实现?
我正在使用此脚本为目录中的所有文件运行它:
for file in ./directory/*; do
fileNameWithExtension="${file##*/}"
fileNameWithoutExtension="${fileNameWithExtension%.*}"
git log branch1..branch2 --author '\(author1\|author2\)' --reverse --pretty=%H $file |
while read commit; do
git stash
git cherry-pick -n --strategy=recursive -n $commit -X theirs
git reset .
git add $file
git commit -m "Random commit to commit the changes: new updates for $fileNameWithExtension" || exit
done
done
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)