Created
February 20, 2019 12:54
-
-
Save debuglevel/3b036e7617e6a85294fdd7db2bda900f to your computer and use it in GitHub Desktop.
bash script which checks if all subdirectories are git repositories with a origin remote set
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 | |
for dir in */ ; do | |
echo -ne "$dir \t " | |
git -C "$dir" rev-parse &> /dev/null | |
CODE=$? | |
if [[ "$CODE" -eq "0" ]]; then | |
echo -ne "is a git repository " | |
git -C "$dir" remote get-url origin &> /dev/null | |
CODE=$? | |
if [[ "$CODE" -eq "0" ]]; then | |
ORIGIN_URL=$(git -C "$dir" remote get-url origin) | |
echo -e "with origin at \t $ORIGIN_URL" | |
else | |
echo -e "with NO origin" | |
fi | |
else | |
echo "is NOT a git repository" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment