Skip to content

Instantly share code, notes, and snippets.

@LucasNevesAraujo
Created January 9, 2019 12:34
Show Gist options
  • Save LucasNevesAraujo/b676132a6dc1295b7cb76d9a5bcf53ad to your computer and use it in GitHub Desktop.
Save LucasNevesAraujo/b676132a6dc1295b7cb76d9a5bcf53ad to your computer and use it in GitHub Desktop.
Update master and develop branches for all sub-directories
# 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