Created
January 13, 2025 07:01
-
-
Save martinamps/e082031f26337350826b48b5d7f7f34c to your computer and use it in GitHub Desktop.
verify all code repos are up to date with your git remote
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
#!/bin/zsh | |
CODE_DIR=~/code | |
for dir in $CODE_DIR/*; do | |
if [ -d "$dir" ]; then | |
echo "Checking: $dir" | |
if [ -d "$dir/.git" ]; then | |
cd "$dir" | |
REMOTE=$(git remote -v | grep fetch | awk '{print $2}') | |
if [ -z "$REMOTE" ]; then | |
echo " ❌ No remote configured." | |
else | |
echo " ✅ Remote configured: $REMOTE" | |
git fetch --quiet | |
LOCAL=$(git rev-parse HEAD) | |
UPSTREAM=$(git rev-parse @{u} 2>/dev/null) | |
if [ "$LOCAL" = "$UPSTREAM" ]; then | |
echo " ✅ Up to date with remote." | |
else | |
echo " ❌ Not up to date with remote." | |
fi | |
fi | |
else | |
echo " ❌ Not a Git repository." | |
fi | |
echo "" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment