Created
July 1, 2010 15:41
-
-
Save dingram/460135 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
# | |
# git-svn-rebase-all | |
# by Dave Ingram <http://github.com/dingram/> | |
# | |
SHELL=${SHELL:-/bin/bash} | |
curbranch=$(git symbolic-ref HEAD 2>/dev/null) | |
if [ $? -eq 0 ]; then | |
curbranch=${curbranch##*/} | |
else | |
curbranch=$(git name-rev --name-only --always HEAD) | |
fi | |
git co master | |
git svn rebase && | |
for branch in $(git br | grep -v \\\*); do | |
git co "$branch" | |
if [[ -n "$( git "config branch.$branch.remote" )" ]]; then | |
# remote tracking branch | |
git svn rebase | |
continue | |
fi | |
fromrev="$( git log --pretty=tformat:%H $branch '^master' | tail -1 )" | |
if [[ -z "$fromrev" ]]; then | |
git merge --ff-only --no-stat master || ( echo "Something went wrong while rebasing $branch"; echo "Exit this shell to continue with other branches"; $SHELL ) | |
else | |
git rebase --onto master "${fromrev}~1" "$branch" || ( echo "Something went wrong while rebasing $branch"; echo "Exit this shell to continue with other branches"; $SHELL ) | |
fi | |
done | |
git co "$curbranch" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment