Created
May 31, 2012 14:14
-
-
Save dbu/2843660 to your computer and use it in GitHub Desktop.
recursive git status
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/php | |
<?php | |
$repos = array(); | |
exec('find -type d -name .git | sed -e "s/\.git//"', $repos); | |
foreach ($repos as $repo) { | |
$status = shell_exec("cd $repo && git status"); | |
if (false == strpos($status, 'nothing to commit (working directory clean)')) { | |
echo "$repo\n" . str_repeat('-', strlen($repo)) . "\n$status\n\n"; | |
} | |
} |
(The
echo off
helps the output look less cluttered but may wreck your prompt. If so, exit the window when done.)
after the command is done, typing echo on
will bring back the prompt.
This one (1) produces a slim output, and (2) starts printing the results instantly (you don't have to wait it to finish to see the final output):
find . -maxdepth 2 -name .git -type d -exec sh -c "cd {}/..; pwd; git status -s" \;
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I discovered from here that if you want to run that script as a git command without making an alias, you have to:
E.g.:
If your PATH contains ~/.local/bin/ and you named your script "git-str" then:
chmod +x git-str && mv git-str ~/.local/bin/
Now you can run: git str.
To any Linux novice, beware of what script you make executable, as it may be dangerous for your system.