Skip to content

Instantly share code, notes, and snippets.

@amelialaundy
Last active August 27, 2018 21:22
Show Gist options
  • Save amelialaundy/8c4eac05b052864e27e184cc16f1b24b to your computer and use it in GitHub Desktop.
Save amelialaundy/8c4eac05b052864e27e184cc16f1b24b to your computer and use it in GitHub Desktop.
pull all changes to given branch for upstream git repos in a folder, default to merge from 'develop' into current branch
#!/bin/bash
[[ $2 = "" ]] && BRANCH_NAME="develop" || BRANCH_NAME="$1"
# Let the person running the script know what's going on.
echo "Pulling in latest changes for all upstream repositories in $pwd..."
echo $BRANCH_NAME;
# Find all folders and update it to the given branch latest revision
for d in */ ; do
echo "";
echo "current repo: $d";
# cd into the folder
cd "$d";
# pull from chosen branch
echo "pulling upstream";
# get upstream changes from main repo;
git fetch upstream;
# merge changes into my fork for given branch name
git merge upstream/$BRANCH_NAME
# lets get back to the parent directory
cd ..;
done
echo "Complete!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment