tldr;
git log --all --numstat \
| grep '^-' \
| cut -f3 \
| sed -E 's|(.*)\{(.*) => (.*)\}(.*)|\1\2\4\n\1\3\4|g' \
| sort -u
解释:
The git-log
option --numstat
以十进制表示法和不带缩写的路径名显示添加和删除的行数,以使其更加机器友好。对于二进制文件,输出两个 - 而不是说 0 0.
Source: https://git-scm.com/docs/git-log https://git-scm.com/docs/git-log,强调我的
这会产生如下所示的输出条目:
commit 0123456789012345678901234567890123456789
Author: Joe Example <[email protected] /cdn-cgi/l/email-protection>
Date: Thu Mar 9 15:33:29 2017 +0000
edit Dockerfile, add assets/foobar.jpg
1 1 Dockerfile
- - assets/foobar.jpg
The grep '^-'
匹配带有前导连字符的行,cut -f3
打印第三个制表符分隔字段,并且
sed -E 's|(.*)\{(.*) => (.*)\}(.*)|\1\2\4\n\1\3\4|g'
检测已移动/重命名的文件并打印源和目标;例如,它会改变这一点:
path/to/{foo => bar}/my-document.pdf
to this:
path/to/foo/my-document.pdf
path/to/bar/my-document.pdf
最后,sort -u
会进行累积、排序和uniquify https://en.wiktionary.org/wiki/uniquify路径列表。
编辑:这个答案假设存在sed
支持扩展正则表达式和捕获组;例如。,https://www.gnu.org/software/sed/ https://www.gnu.org/software/sed/ .