我想检索一组路径中的修订文件的路径,权限和内容哈希列表,但不包括某些路径。
git ls-tree
似乎很完美。例如,在Git仓库中,
$ git ls-tree -r v2.2.2 -- Documentation ':!Documentation/RelNotes'
100644 blob ddb030137d54ef3fb0ee01d973ec5cee4bb2b2b3 Documentation/.gitattributes
100644 blob 2c8b2d612ee0d6c1f687bfa062bb7fe6471d9280 Documentation/.gitignore
100644 blob 894546dd75416fcf09542096a67b2f22a7d0de7a Documentation/CodingGuidelines
100644 blob 2f6b6aabd74a24abdb3ac189118095fcee19f8d2 Documentation/Makefile
100644 blob fa71b5f0b62f43483d02c24d809e6282fa49576a Documentation/SubmittingPatches
100644 blob 2c16c536ba830ec12bbf335d09f689d23e325197 Documentation/asciidoc.conf
100644 blob 0cebc4f6927211ffbc013de9368f03f480dba65d Documentation/blame-options.txt
100755 blob ba4205e0302a267a5da6bef504f3e69eb0c4aa6d Documentation/build-docdep.perl
100755 blob 87437f8a95768595e040b8c4c1d48e5c29ada087 Documentation/cat-texi.perl
但是这在2.3.0中是removed,带有消息
ls-tree:禁用负路径规范,因为它不受支持
那是通告;)
在git 2.3.0及更高版本中执行此操作的新方法是什么?
答案 0 :(得分:1)
管道穿透
awk '$4 !~ /Documentation\/RelNotes/ { print }'
......是显而易见的方法。为了使这更通用:
s='Documentation/RelNotes'
awk -v exclusion_re="$s" '$4 !~ exclusion_re { print }