如何从 git diff 命令中排除 blade 文件?

How to exclude blade files from git diff command?

我有以下命令来获取文件,我想排除所有 .blade.php 个文件。

$(git diff --cached --name-only --diff-filter=ACM | grep ".php\{0,1\}$")

我该怎么做?

我试过这些方法:

  1. $(git diff --cached --name-only --diff-filter=ACM | grep --exclude="*\.blade.php*"| grep ".php\{0,1\}$")
    
  2. $(git diff --cached --name-only --diff-filter=ACM | grep --exclude="*\.blade.php*" ".php\{0,1\}$")
    

但是上面的 none 是有效的。

一种是使用grep -v排除匹配模式的文件。

git diff --cached --name-only --diff-filter=ACM | grep ".php\{0,1\}$" | grep -v '.blade.php$'

另一种是排除git diff中的文件。

git diff --cached --name-only --diff-filter=ACM -- . ':!*.blade.php' | grep ".php\{0,1\}$"

-- . ':!*.blade.php'表示当前文件夹下除符合模式*.blade.php的文件外的所有文件。