Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to do Git status for all repos in subfolders?

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).

like image 292
kramer65 Avatar asked Jun 24 '14 15:06

kramer65


2 Answers

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
like image 110
gniourf_gniourf Avatar answered Oct 12 '22 23:10

gniourf_gniourf


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
like image 41
meagar Avatar answered Oct 12 '22 23:10

meagar