Skip to content

Instantly share code, notes, and snippets.

@troyxmccall
Last active December 25, 2015 15:39
Show Gist options
  • Save troyxmccall/6999498 to your computer and use it in GitHub Desktop.
Save troyxmccall/6999498 to your computer and use it in GitHub Desktop.

place this file in your project root

chmod +x updateprojects.sh

to make it executable, then run

sh updateprojects.sh

to update all your git projects

#!/bin/bash
# store the current dir
CUR_DIR=$(pwd)
#hey user
echo "Pulling in latest changes for all repositories..."
# Find all git repositories and update it to the master latest revision
for i in $(find . -name ".git" | cut -c 3-); do
if [[ "$i" != *libraries* ]]
then
#list your submodule directories: here, ie I have a git submodule called deployment
if [[ "$i" != *deployment* ]]
then
echo "";
echo $i;
#We have to go to the .git parent directory to call the pull command
cd "$i";
cd ..;
#pull checked out branch
git pull;
#update submodules
git submodule update;
#lets get back to the CUR_DIR
cd $CUR_DIR
fi
fi
done
echo "Complete!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment