对每个更改的文件执行命令

Paw*_*ski 4 git bash

我想对每个没有暂存更改的文件执行一些 shell 命令。

例如,如果git status显示

On branch xxxxxxx
Your branch is up-to-date with 'origin/xxxxxxxxx'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    modified:   client/.../reports.coffee
    modified:   client.../tools.coffee
Run Code Online (Sandbox Code Playgroud)

我想对文件reports.coffeetools.coffee.

我不想使用,find因为文件可以在不同的时间更改。我怎样才能做到这一点?

dvx*_*xam 5

你也可以使用这个命令:

git status -s | grep '??' | cut -f2 -d' ' | xargs echo

并替换echo为您要执行的命令


Laj*_*jos 5

我想出了这个无逻辑的解决方案:git diff --name-only | xargs -I{} echo {}