Friday, July 17, 2009

How to version control your projects with bazaar

So you have a project named 'supercool' that happens to sit in a directory named (what else) 'supercool'. Assuming you have bazaar installed on your client computer and the server, this is how you start a project under a centralized "lock-step" model. IMHO, this model works best for solo projects if you have a server available to you:


cd supercool # make sure you are at the top level directory of your project
bzr init # starts up version control in this directory (an independent branch right now)
bzr add # will recursively add files in your project
bzr ci -m 'initial commit' # makes a commit to your branch
# the next step assumes you have already made the directory /home//bzr on your server
# this step will create a centralized repository on your remote
bzr push sftp://<user>@myserver.domain.org/home/<user>/bzr/supercool
# now, we need to 'bind' our independent branch to the remote branch
# which transforms it into "centralized mode"
bzr bind sftp://<user>@myserver.domain.org/home/<user>/bzr/supercool

# to check out a fresh copy on a different computer
bzr co sftp://<user>@myserver.domain.org/home/<user>/bzr/supercool


So, now you can work on files in your project and have them versioned. Your daily work-flow will look like this:

# assuming you are in your project directory...
bzr up # update your repo with any changes in the centralized repo
## do some work...
bzr add <file1> <file2> # add any new files, etc.
bzr ci -m 'adding new files, changed some other ones'

That's it! The bazaar documentation is great, particularly the user guide.