Skip to content

Instantly share code, notes, and snippets.

@db6edr
Forked from douglas/update_git_repos.sh
Last active March 7, 2017 07:27
Show Gist options
  • Save db6edr/b82e936567d43c5289b6102609a84f8b to your computer and use it in GitHub Desktop.
Save db6edr/b82e936567d43c5289b6102609a84f8b to your computer and use it in GitHub Desktop.
Update all git repositories under a base directory
#!/bin/bash
# store the current dir
CUR_DIR=$(pwd)
# Let the person running the script know what's going on.
echo -e "\n\033[1mPulling in latest changes for all repositories...\033[0m\n"
# Find all git repositories and update it to the master latest revision
for i in $(find . -maxdepth 2 -name .git -type d ); do
echo "";
echo -e "\033[33m"+$i+"\033[0m";
# go to git-dir of a repo, then up 1 to be in the actual repo
cd "$i";
cd ..;
# finally pull
git pull origin master;
# lets get back to the CUR_DIR
cd $CUR_DIR
done
echo -e "\n\033[32mComplete!\033[0m\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment