Last active
January 15, 2019 03:19
-
-
Save greatbody/5218ae10d4b7acb7053bb7dcfe761e87 to your computer and use it in GitHub Desktop.
Say you have a project with many repos and you can run this scripts to pull all git repos inside a folder
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/sh | |
red=`tput setaf 1` | |
green=`tput setaf 2` | |
reset=`tput sgr0` | |
echo_green() | |
{ | |
echo "${green}$1${reset}" | |
} | |
echo_red() | |
{ | |
echo "${red}$1${reset}" | |
} | |
arr=($(ls -d */)) | |
for i in "${arr[@]}" | |
do | |
# do whatever on $i | |
echo_green "Processing $i..." | |
cd $i | |
echo_green "Stashing..." | |
git stash | |
cbranch=$(git branch | grep \* | cut -d ' ' -f2) | |
echo_green "Checkout to master..." | |
git checkout master | |
echo_green "Pull latest commit(s).." | |
git pull | |
echo_green "Check out to ${cbranch} and Unstashing..." | |
git checkout $cbranch | |
git stash pop | |
cd .. | |
echo_red "------------------------------" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment