Created
August 29, 2012 18:45
-
-
Save wereHamster/3516957 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env bash | |
# Do an octopus merge and select a strategy for each branch you | |
# want to merge. | |
STRATEGY="recursive" | |
HEADS=( $(git rev-parse HEAD) ) | |
git checkout HEAD^{} | |
while [ $# -gt 0 ]; do | |
if [ "$1" = "-s" ]; then | |
shift; STRATEGY="$1" | |
else | |
printf "Merging $1 with $STRATEGY strategy... " | |
HEADS[${#HEADS[*]}]=$(git rev-parse $1) | |
if ! git merge -s $STRATEGY $1 1>/dev/null 2>&1; then | |
printf "failed\n"; exit 1 | |
fi | |
printf "\n" | |
fi | |
shift | |
done | |
n=$(( ${#HEADS[*]} - 1 )) | |
git reset --soft HEAD~$n | |
rm -f .git/MERGE_HEAD | |
for head in ${HEADS[@]}; do | |
echo $head >> .git/MERGE_HEAD | |
done | |
git commit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment