Created
October 6, 2022 12:02
-
-
Save innomatics/e9eca3b95644982bdffb0aac0258b842 to your computer and use it in GitHub Desktop.
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/bash | |
# Every folder in the script path should be a git repository. | |
# Update each folder/repo with a remote pull (if they are on the default branch). | |
set -e | |
REMOTE=origin | |
for folder in $(find .. -mindepth 1 -maxdepth 1 -type d); do | |
if [ -d $folder/.git ]; then | |
pushd $folder | |
default_branch=$(git remote show $REMOTE | sed -n '/HEAD branch/s/.*: //p') | |
current_branch=$(git branch --show-current) | |
if [ "$default_branch" == "$current_branch" ]; then | |
echo git pull $REMOTE $current_branch | |
else | |
echo Skipping repo in $folder \($current_branch\) because its not on $default_branch. | |
fi | |
popd | |
fi | |
done | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment