Skip to content

Instantly share code, notes, and snippets.

@nfreear
Forked from dbu/git-status-recursive
Last active August 1, 2017 10:36
Show Gist options
  • Save nfreear/55b52827c46485218129b6b00b73adb9 to your computer and use it in GitHub Desktop.
Save nfreear/55b52827c46485218129b6b00b73adb9 to your computer and use it in GitHub Desktop.
Recursive git status (PHP + Bash)
#!/usr/bin/env php
<?php
/**
* Recursive Git status.
*
* @author NDF, 01-August-2017 (edits only)
* @link https://gist.github.com/dbu/2843660
* @link https://gist.github.com/nfreear/55b52827c46485218129b6b00b73adb9
*/
define( 'FIND_CMD', 'find . -type d -name \'.git\' | sed -e "s/\.git//"' );
define( 'GIT_CLEAN', 'nothing to commit, working tree clean' );
$repos = [];
exec( FIND_CMD, $repos );
foreach ($repos as $repo) {
$status = shell_exec( "cd $repo && git status" );
if (false === strpos( $status, GIT_CLEAN )) {
echo ">> $repo\n" . str_repeat( '-', strlen($repo) + 3 ) . "\n$status\n";
}
}
# End.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment