Created
January 9, 2019 12:34
-
-
Save LucasNevesAraujo/b676132a6dc1295b7cb76d9a5bcf53ad to your computer and use it in GitHub Desktop.
Update master and develop branches for all sub-directories
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
# List all directories | |
for D in $(ls -1d $PWD/*); do | |
if [ -d "${D}" ]; then | |
# Check if has a git folder | |
DIRECTORY="${D}/.git" | |
if [ -d "$DIRECTORY" ]; then | |
cd ${D} | |
echo ${D} | |
# Get the current branch | |
branch=$(git branch | grep \* | cut -d ' ' -f2); | |
# Udate master and develop | |
git fetch && git checkout master && git pull && git checkout develop && git pull | |
# Go back to the previous branch | |
git checkout ${branch} | |
# Go back to the parent folder | |
cd .. | |
fi | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment