Don’t Lose Your Head With Bazaar

Here at SRT Solutions, we’ve become big fans of the distributed version control system Bazaar. While my personal experience with Bazaar has been very good overall, I ran into a very scary situation the other day.

I was away from a connection to our main Bazaar repository for a few days, so I had quite a few local commits saved up. When I was able to reconnect, I did a ‘bzr update’ to pull the latest revisions from our repository. A careful look at the output from the update command showed the startling fact that Bazaar had erased all of my changes. All the changes I made to existing files were reverted, all my new files were deleted, and all of my work from the past few days was nowhere to be found. At first, I wasn’t too worried, but the more I looked into things, the more I started to panic.  ‘bzr status’ showed nothing. ‘bzr log’ didn’t mention my local commit messages.  ‘bzr revert’ did nothing. It was like Bazaar forgot about all of my changes and erased them from the file system- not good for a version control system.

Help came in the form of Jay Wren who suggested that I try ‘bzr heads’. After fumbling with that command, I finally was able to get ‘bzr heads –all’ to tell me that I had a two heads. Each head was the root of a branch, so basically the output was telling me that there were two branches, my branch with the local commits (the dead branch) and the one that I just pulled from the repository with an update (the live branch). Here’s what the output looked like:

$ bzr heads –all
HEAD: revision-id: <my local rev-number>(dead)
  committer: <me>
  branch nick: <local branch nick>
  timestamp: <some timestamp>
    <the commit message from my local branch>

TIP of branch: <path to branch tip>
HEAD: revision-id: <some other rev-number>
  committer: <someone else>
  branch nick: <their branch nick>
  timestamp: <some timestamp>
    <a commit message from someone else>

A simple ‘bzr revert -r revid:<my local rev-number>’ restored my changes and and my heartbeat. From there I was able to ‘bzr update’ again, and for some reason everything worked out fine this time. I’ve unsuccessfully tried to recreate this problem, but I think that it has something to do with mixing svn-style bound branches with unbound branches. At least I know that I won’t (wait for it) be loosing my head (groan) if this happens to me again.

This entry was posted in Bazaar. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.


  1. En-Cu-Kou
    Posted February 6, 2009 at 6:38 pm | Permalink

    The proper command to use is:

    bzr pull . –overwrite -r revid:dead-revid

    The problem with bzr revert is that the changed files show up as modified/added/removed, and have to be checked in. `bzr pull` recovers the “lost” revisions themselves, along with commit messages etc.
    Afterwards, run bzr update normally.

    Thanks to bialix on #bzr for explaining and CaMason for bringing it up.

  2. bialix
    Posted February 6, 2009 at 6:41 pm | Permalink

    bzr pull . –overwrite -r revid:
    will restore your history too.

  3. cmarinos
    Posted February 7, 2009 at 8:58 am | Permalink

    Thanks for the info. If I run into this problem again, I’ll have to try the “bzr pull –overwrite” suggestion.

  4. Drew
    Posted September 27, 2009 at 9:43 am | Permalink

    Dude, thank you so much for this page. I ran into exactly the same problem except I’ve found several dead HEADs.

  5. cmarinos
    Posted September 27, 2009 at 3:00 pm | Permalink


    No problem. Glad I could help.


  6. Dave Miller
    Posted March 14, 2010 at 8:48 pm | Permalink

    Thanks, that was exactly what I needed to get back my missing revisions!

  7. Andrew Reid
    Posted August 15, 2012 at 8:09 pm | Permalink

    This is a pretty HUGE bug in the update command, whose purpose as I understand it is to merge local changes (including new files) with the master branch.

    Just lost a bunch of code, and no “dead” head is showing up in the list. Everything just disappeared. Makes me question my choice to use Bazaar, and I’ve been using it for a few years.

  8. Chris Marinos
    Posted August 16, 2012 at 9:03 pm | Permalink


    I agree, it’s a pretty bad bug. Honestly, I’d recommend switching to git or hg at this point since bzr seems to be pretty behind the curve in both community mindshare and hosting options. I’ve successfully used the approach described at to migrate a small bzr repo to git. It worked great, but I’m not sure how it scales.

    Best of luck to you however you go!


Post a Comment

Your email is never published nor shared. Required fields are marked *

You may use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>