Created
July 14, 2022 15:01
-
-
Save initbar/46294ffdd33c425ea9786f29c74dc46f to your computer and use it in GitHub Desktop.
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 i in $(ls | shuf); do | |
[ -d "$i" ] && { | |
[ -d "$i/.git" ] && ( | |
cd "$i" | |
branch="$(git rev-parse --abbrev-ref HEAD)" | |
if [[ "${branch}" == 'main' || "${branch}" == 'master' ]]; then | |
: | |
else | |
git reset --hard HEAD | |
git checkout main || git checkout master | |
fi | |
while :; do | |
echo -e ">>> Syncing\t$i: ${branch}" | |
{ | |
git reset --hard HEAD &&\ | |
git pull origin HEAD | |
} &> /dev/null | |
[[ $? == 0 ]] && { | |
echo -e "<<< Synced\t$i" | |
echo '---' | |
break | |
} | |
echo -e "<<< Retrying\t$i" | |
sleep 5 | |
done | |
) | |
} | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment