I would like to execute some shell command on every file that has not staged changes.
For example, if git status
shows
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
I want to execute command on files reports.coffee
and tools.coffee
.
I don't want to use find
because files can change in different time. How can I achieve that?
You could also use this command :
git status -s | grep '??' | cut -f2 -d' ' | xargs echo
and replace echo
by the command you want to execute
This is a better starting pattern:
git status -s | grep '.M ' | cut -c 4- | xargs echo
Change .M
to states you are looking to capture.
cut -c 4-
simply cuts out first 3 characters and returns only 4th and to the end.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With