In my day-to-day git workflow, I have many topic branches, like so:
o--o--o (t2) / o--o (t1) / o--o--o (master)
Don't rebase. Start your features from a common point. Merges are way less work in the end.
This is what we do:
http://dymitruk.com/blog/2012/02/05/branch-per-feature/
Pretty much the same question was asked on the git mailing list: Rebasing Multiple branches at once... The linked response has a perl script attached that generates the commands you would need.
If you want this script to be fast and avoid having it tread on your toes, also consider using git-new-workdir
to set up a working copy just for automatic rebasing.
If you find yourself resolving the same conflicts over and over, consider enabling git rerere.
Having said all that, here is an alternate recipe:
# Construct a placeholder commit that has all topics as parent.
HEADS="$(git for-each-ref refs/heads/\*)" &&
MAGIC_COMMIT=$(echo "Magic Octopus"$'\n\n'"$HEADS" |
git commit-tree \
$(git merge-base $(echo "$HEADS" | sed 's/ .*//' ))^{tree} \
$(echo "$HEADS" | sed 's/ .*//;s/^/-p /')) &&
git update-ref refs/hidden/all $MAGIC_COMMIT
# Rebase the whole lot at once.
git rebase --preserve-merges master refs/hidden/all
# Resolve conflicts and all that jazz.
# Update topic refs from the rebased placeholder.
PARENT=
echo "$HEADS" |
while read HASH TYPE REF
do
let ++PARENT
git update-ref -m 'Mass rebase' "$REF" refs/hidden/all^$PARENT "$HASH"
done
There's a new tool that allows to automate such tasks: git-assembler
Here's a direct link to the example in the documentation for rebasing local branches
You shouldn't dismiss TopGit immediately though. The ability to generate email patches is entirely optional.