• en 文件名 : OK
     
$ git ls-files origin/dev | grep  'xx(副本)copy(副本).xxxxx'
$ git ls-files  'xx(副本)copy(副本).xxxxx'
"xx(\345\211\257\346\234\254)copy(\345\211\257\346\234\254).xxxxx"
$ git ls-files origin/dev  'xx(副本)copy(副本).xxxxx'
"xx(\345\211\257\346\234\254)copy(\345\211\257\346\234\254).xxxxx"
$ git ls-tree origin/dev  'xx(副本)copy(副本).xxxxx'
100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391    "xx(\345\211\257\346\234\254)copy(\345\211\257\346\234\254).xxxxx"

git ls-tree / ls-tree 获得的中文文件名,是转义后的

$ git ls-tree origin/dev  'aa (副本) copy (副本) (副本).xxxxx'
100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391    "aa (\345\211\257\346\234\254) copy (\345\211\257\346\234\254) (\345\211\257\346\234\254).xxxxx"

显示不正确:没有显示结果

  • 由于 git ls-tree / ls-tree 获得的文件名,是转义后的。所以 grep 在这里没有正确的结果显示。

$ git ls-tree origin/dev  | grep 'aa (副本) copy (副本) (副本).xxxxx'

find 获得的中文文件名,是原样的

$ find . -name 'xx(副本)copy(副本).xxxxx' | grep 'xx(副 本)copy(副本).xxxxx'
./xx(副本)copy(副本).xxxxx

$ find . -name    'xx(副本)copy(副本).xxxxx'
./xx(副本)copy(副本).xxxxx

Logo

汇聚全球AI编程工具,助力开发者即刻编程。