Skip to content

Instantly share code, notes, and snippets.

@siwonpawel
Created March 16, 2022 15:18
Show Gist options
  • Save siwonpawel/9f0b86958ad3f57c44726b4770c50e98 to your computer and use it in GitHub Desktop.
Save siwonpawel/9f0b86958ad3f57c44726b4770c50e98 to your computer and use it in GitHub Desktop.
Update all repos with bash
#!/bin/bash
for dir in */ ; do
cd $dir
pwd
echo "**** fetching all ****"
git fetch --all
echo "**** update master ****"
branch=$(git rev-parse --abbrev-ref HEAD)
if [ "$branch" = "master" ]; then
git pull
else
git fetch origin master:master
fi
echo -e "\n\n****************************"
cd ..
done
echo -e "\n\n"
read -p "Press enter to close..."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment