Script that rebases a bunch of branches and merges them into one.
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
# Usage: reb.sh branch_base new_base | |
set -e | |
git checkout --detach | |
oldbase=`git show-ref --heads -s "$1/base"` | |
branches=`git branch --list "$1/*"` | |
git checkout "$1/base" | |
git reset --hard $2 | |
to_merge="" | |
for b in $branches | |
do | |
if [ $b == "$1/base" ] || [ $b == "$1/work" ] | |
then | |
continue | |
fi | |
# TODO check if branch is already ok (base is in) | |
git rebase --onto "$1/base" $oldbase $b | |
to_merge="$to_merge $b" | |
done | |
git checkout "$1/work" | |
git reset --hard "$1/base" | |
git merge --no-edit $to_merge |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment