Skip to content

Commit

Permalink
Add script to rebase merge topic branch
Browse files Browse the repository at this point in the history
  • Loading branch information
owenthereal committed Apr 25, 2012
1 parent 0aa2c5e commit 5481af4
Showing 1 changed file with 73 additions and 0 deletions.
73 changes: 73 additions & 0 deletions git-rebase-merge
@@ -0,0 +1,73 @@
#!/usr/bin/env bash

git.current_branch() {
br=`git branch | grep "*"`
echo ${br/* /}
}

git.checkout() {
git checkout $1
}

git.fetch() {
git fetch origin
}

git.pull() {
git pull origin $1
}

git.rebase() {
git rebase -i origin/$1
}

git.force_push() {
git push -f origin $1
}

git.push() {
git push origin $1
}

git.merge() {
git merge --edit $1
}

git.delete_branch() {
git branch -D $1 &&
git push origin :$1
}

merge() {
git.fetch &&

git.checkout $2 &&
git.pull $2 &&
git.rebase $1 &&
git.merge $1 &&
git.force_push $2 &&

git.checkout $1 &&
git.pull $1 &&
git.merge $2 &&
git.push $1 &&

git.delete_branch $2
}

main() {
if [ $# = 0 ]
then
echo "Usage: git-rebase-merge <topic-branches>"
exit 0
fi

for b in $*
do
echo "Merging $b to $(git.current_branch)..."

merge $(git.current_branch) $b
done
}

main $*

0 comments on commit 5481af4

Please sign in to comment.