Created
December 6, 2013 22:17
-
-
Save deckerego/7833085 to your computer and use it in GitHub Desktop.
Mass-create branches in multiple Git repos and push them remote
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/sh | |
PROJECTS="Project_1 Project_2 Project_3" | |
BRANCH="$1" | |
if [[ -z "$BRANCH" ]]; then | |
echo "Usage $0 BRANCH_NAME" | |
exit -1 | |
fi | |
for PROJECT in $PROJECTS | |
do | |
echo "Creating $PROJECT branch $BRANCH" | |
CURRENT_DIR=$PWD | |
cd $PROJECT | |
git checkout -b "$BRANCH" | |
git config "branch.$BRANCH.remote" origin | |
git config "branch.$BRANCH.merge" "refs/heads/$BRANCH" | |
git push origin "$BRANCH" | |
SUCCESS=$? | |
if [[ $SUCCESS -ne 0 ]]; then | |
echo "** ERROR CREATING BRANCH $BRANCH FOR REPO $PROJECT **" | |
exit $SUCCESS | |
fi | |
cd $CURRENT_DIR | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment