I've got a folder, which contains about 10 subfolders each containing a separate git repo. So something like this:
MainFolder/:
-- GitRepoA/
-- GitRepoB/
-- GitRepoC/
-- GitRepoD/
-- etc.
I often want to check whats going on, specifically I would like a command which lists the output for git status
for all subfolders in which something has changed. Does anybody know a solution for this? (I'm on Mac OSX by the way).
If you need recursion (or will work as well if you don't):
find . -name .git -type d -execdir git status \;
For each directory named .git
will execute git status
from within the directory that contains it (-execdir
). Wow, exactly what you want.
You can append -prune
too so as to not go further in subdirectories of a git project to be more efficient (but might skip git submodules—I have no ideas how submodules work I never use them):
find . -name .git -type d -execdir git status \; -prune
Iterate over each directory, and set the working directory and .git
directory with the commandline options --work-tree
and --git-dir
respectively:
for x in *; do git --work-tree="$x" --git-dir="$x/.git" status; done
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