Cas*_*bel 10
不,不幸的是.
我想我可以看到工作--Git根据当前索引中的内容生成一个临时文件,将其与当前工作树版本的副本一起交给difftool(以保护您不做进一步更改),让您使用difftool将一些更改移动到索引版本,然后一旦保存并退出,就会对修改后的索引版本中的任何内容进行分阶段.请注意,这将需要difftool也是一个编辑器,并不是所有有效的difftools; 其中一些仅用于查看差异.还需要注意的是,这是基本上绕过所有的git add -p.你不会有任何正常的界面来在帅哥之间移动,分裂帅哥等等.difftool将完全负责所有这一切.
如果你的difftool功能足以完成这类工作,那么我想你可以编写一个脚本来完成它.大纲,没有任何错误保护,处理特殊情况(二进制文件?),并且完全未经测试:
#!/bin/bash
tmpdir=$(mktemp -d)
git diff --name-only |
while read file; do
cp "$file" $tmpdir
# this has your changes in it
work_tree_version="$tmpdir/$file"
# this has the pristine version
index_version=$(git checkout-index --temp "$file")
# and now you bring changes from the work tree version into the index version,
# within the difftool, and save the index version and quit when done
my_difftool "$work_tree_version" "$index_version"
# swap files around to run git add
mv "$file" "$work_tree_version"
mv "$index_version" "$file"
git add "$file"
mv "$work_tree_version" "$file"
# you could also do this by calculating the diff and applying it directly to the index
# git diff --no-index -- "$file" "$original_index_version" | git apply --cached
rm -r $tmpdir
Run Code Online (Sandbox Code Playgroud)
可能有很多方法可以改善它; 抱歉,我现在没有时间小心谨慎.
| 归档时间: |
|
| 查看次数: |
2603 次 |
| 最近记录: |