Created
April 9, 2013 17:28
-
-
Save samba/5347643 to your computer and use it in GitHub Desktop.
Find dirty Git directories (i.e. projects with uncommitted changes)
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/sh | |
git_command_context () { | |
cd $1; | |
shift; | |
is_workdir=`git rev-parse --is-inside-work-tree` | |
is_gitdir=`git rev-parse --is-inside-git-dir` | |
is_basedir=`git rev-parse --is-bare-repository` | |
my_gitdir=`git rev-parse --git-dir` | |
git "--work-tree=`pwd`" "--git-dir=${my_gitdir}" "$@" | |
cd $OLDPWD; | |
} | |
echo_if_dirty(){ | |
while read gitdir; do | |
workdir=`dirname "$gitdir"` | |
[ -z "`git_command_context "${workdir}" diff --shortstat 2>/dev/null | tail -n 1`" ] || echo "dirty:" $workdir | |
done | |
} | |
find ${1:-./} -type d -name .git | echo_if_dirty |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment