Created
December 11, 2018 19:49
-
-
Save arne-cl/c7079d8a5a4c26cc15655575f0b72807 to your computer and use it in GitHub Desktop.
List all git repositories with uncommitted code / unpushed commits in the current dir
This file contains 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
#!/bin/bash | |
# This script lists all git repositories in the current directory | |
# that contain uncommited code or have unpushed commits. | |
# recursively list all directories (three levels deep) that don't have | |
# '.git' in their path. | |
# | |
# 'while read LINE' and 'cd "$LINE"' are used to handle paths that | |
# would need escaping. | |
find ./ -maxdepth 3 -type d | grep -v /\.git | while read LINE; do | |
( # start subshell | |
cd "$LINE" && \ | |
result=`git cherry -v 2>/dev/null`; rc=$? && \ | |
# if the stdout of git-cherry is not an empty string | |
if [ -n "$result" ]; then | |
echo $(pwd) | |
fi | |
) # end subshell | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment