pruning history from branch - rebase?

John Arbash Meinel john at
Fri Mar 20 23:24:30 GMT 2009

Hash: SHA1

David Reitter wrote:
> I'm looking for a bit of advice on how to combine about 15 years worth
> of changes in an active upstream project into just one revision within
> my downstream branch, i.e.
> combining revisions 1..80000 or so into a single one.
> I understand (from [1]) that rebase should be able to do this.  [2]
> lists a recipe that I will try to follow.
> My question is:
> - Will I be able to merge new revisions taking place in the upstream
> branch easily into mine?  (Logically I don't see a problem.)
> - Will I be able to push changes in my branch upstream, or at least
> generate working merge bundles?
> Thanks
> - David
> PS.: It would be nice if rebase provided a command to do this.  Also,
> can I suggest to improve the explanation of the "-r" argument of "bzr
> rebase" in its --help text?

I'm not sure I understand what you are thinking about combining 80k
revisions, but conceptually:

bzr init
bzr commit -m "initial null revision"
bzr merge -r0..-1 ../big-project
bzr revert --forget-merges
bzr commit

Will merge the current content of the files, and not the actual
ancestry. Though this is much easier to achieve with:

cd big-project
bzr export ../tiny-project
cd ../tiny-project
bzr init
bzr add --file-ids-from ../big-project
bzr commit -m "Initial snapshot of 'big-project'"

At this point, you have a tree with all the same file ids, but none of
the history.

Merging will be an issue, because all of these files don't share any
ancestry yet. If you just want to be able to commit locally, and merge
that into big-project, you could do:

cd ../big-project
bzr merge -r 0..-1 ../tiny-project
# This should actually do very little to your working tree, as long as
# you do it with the exact version that you exported.
# the merge algorithm should notice that all the content is identical,
# and allow clean resolutions of introducing identical content
bzr commit -m "bring in the first rev of tiny-project"

Now the two ancestry graphs have joined, and you can trivially merge all
of the changes from 'tiny-project' into 'big-project'.

Note that the *reverse* is not 100% true. Specifically, tiny-project has
none of the ancestry of big-project. If you want to merge from
big-project back into tiny-project, you have to use a 'cherry-pick' to
do so (assuming you don't want to actually ever bring in the rest of the
ancestry of big-project, which I assume was the whole point of the

Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla -


More information about the bazaar mailing list