#!/bin/bash # find untracked files in git working copies (under the specified directory) # directory containing working copies DIR_ROOT=$1 if [[ ! $DIR_ROOT ]] || [[ ! -d $DIR_ROOT ]]; then echo "Usage: $0 root_dir" exit 1 fi # remember work dir ORIG_DIR=$PWD # search working copies for GITDIR in $( find $DIR_ROOT -name .git -type d ); do WORKCOPY=${GITDIR%/.git} cd $WORKCOPY GITSTATUS=$( git status --porcelain ) if [ -n "$GITSTATUS" ]; then echo "Untracked files in $WORKCOPY" echo "$GITSTATUS" echo fi # restore work dir cd $ORIG_DIR done