Skip to content

Instantly share code, notes, and snippets.

@tmhedberg
Created July 18, 2011 18:55
Show Gist options
  • Save tmhedberg/1090322 to your computer and use it in GitHub Desktop.
Save tmhedberg/1090322 to your computer and use it in GitHub Desktop.
Rebase a "tree" (connected DAG) of Git branches onto a common new base
#!/bin/bash
branches=$(
git branch --contains `
git rev-list $1..$2 |
tail -n 1
` |
sed 's/^..//'
)
echo $branches
echo -n 'Rebase these branches? Warning: merges will not be preserved! (y/n)>'
read
[[ $REPLY != y ]] &&
exit
for b in $branches; do
git rebase --committer-date-is-author-date $1 $b
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment