Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Git Pending Repos
# add this code to your .bashrc file
# gitpending() transverses from the current directory to
# inspect 1 directory level deep for any git repos that have
# pending changes to commit.
function gitpending()
{
for d in */ ; do
pushd $d > /dev/null
DIRNAME=$(basename "$d")
if ! git diff-index --quiet HEAD --; then
echo $DIRNAME
fi
popd > /dev/null
done
}
# example usage:
#
# ~/$ cd go/src/github.com/eduncan911
# ~/go/src/github.com/eduncan911$ gitpending
# eduncan911.github.io
# go-mspec
# go
# ~/go/src/github.com/eduncan911$
#
# the above example looked at all directories I had
# under ~/go/src/github.com/eduncan911 to find 3
# directories with pending changes:
#
# eduncan911.github.io
# go-mspec
# go
#
# (i currently have 11 repos in that directory; so
# in other words, it found 3 with pending changes)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment