Last active
March 16, 2018 13:08
-
-
Save Skitionek/48877928b008f1e37e0922c944779be1 to your computer and use it in GitHub Desktop.
Recursive traverse folders finding the git repositories and listing the uncommitted changes. Additionally, if the pair with the same name was found compare them with git diff.
This file contains hidden or 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
#!/usr/local/bin/bash | |
clear | |
# just for formatting | |
b=$(tput bold) | |
n=$(tput sgr0) | |
declare -A reppos | |
find . -name .git -print0 | xargs -0 -n1 dirname | sort --unique | while read -r dir | |
do | |
reppo="${dir##*/}" | |
echo "-- ${dir%/*}/${b}${reppo}${n} --" | |
if [ ${reppos[$reppo]+_} ] | |
then | |
echo "Found another copy of this reppo in ${reppos[$reppo]}." | |
diff=$(git diff --shortstat ${reppos[$reppo]} ${dir}) | |
if [[ -z "${diff// }" ]] | |
then | |
echo "The copies are identical." | |
else | |
echo "Comparing these two yield: ${diff}"; | |
fi | |
else | |
reppos[$reppo]=${dir} | |
fi | |
dir=${dir%*/} | |
{ | |
(cd ${dir} && git status -s) | |
} || { | |
echo "Repository error!" | |
} | |
echo | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example output: