Created
February 25, 2016 21:46
-
-
Save billimek/595975c5a5345f9e58de 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 | |
# Store the current directory | |
current_directory=$(pwd) | |
# Setup colours | |
c_reset='\033[00m' | |
c_highlight='\033[33m' | |
echo -e "\n${c_highlight}Pulling in latest changes for all repositories...${c_reset}" | |
# Find all git repositories | |
for i in $(find . -maxdepth 3 -name ".git" | cut -c 3-); do | |
# Change the repository directory. | |
cd "$i/.."; | |
echo -e "\n${c_highlight}${PWD##*/}${c_reset}"; | |
# Update repository. | |
if (`git branch -r| grep -q origin`); then | |
git pull origin master; | |
fi | |
if (`git branch -r| grep -q upstream`); then | |
git fetch upstream; | |
git merge upstream/master | |
fi | |
# Back to current directory. | |
cd $current_directory | |
done | |
echo -e "\n${c_highlight}Complete!${c_reset}\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment