Created
December 8, 2015 19:11
-
-
Save slucero/258dda2ac764cd5550f8 to your computer and use it in GitHub Desktop.
Git command script to merge a single branch into multiple others.
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/bash | |
############################## | |
# Merge the current branch into multiple other local branches. | |
# | |
# TODO: Add the option to pass additional arguments to merge commands | |
############################## | |
# Determine the current branch name | |
source=$(git symbolic-ref HEAD 2> /dev/null) || source=$(git rev-parse --short HEAD 2> /dev/null); | |
# Strip prefix from branch name | |
source=${source#refs/heads/}; | |
targets=$*; | |
for target in $* | |
do | |
git checkout $target; | |
if ! git merge --no-ff $source; then | |
printf 'Failed to merge "%s" into "%s"\n' $source $target >&2 | |
exit 1 | |
fi | |
git checkout $source; | |
done | |
exit 0; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment