Working on several branches at the same time

Ben Finney bignose+hates-spam at benfinney.id.au
Sun Jun 15 12:01:06 BST 2008


David Cournapeau <david at ar.media.kyoto-u.ac.jp> writes:

> Hi,
> 
>    I have recently encountered the following situation:
> 
> - I have a branch mainline, from which I want to add a new feature
> - I am working on a new feature in branch newfeat.
> - While working on newfeat, I realize something is broken, which
> prevents me from working further in newfeat.
> - I create another branch from mainline to fix the bug.
> 
> How do I go after that ?

My workflow would be:

- branch 'mainline' to 'bugfix-foo'
- fix bug in 'bugfix-foo' branch
- run test suite, fix any errors
- commit

- switch to 'mainline' branch
- merge from 'bugfix-foo'
- run test suite, fix any errors
- commit

- switch to 'newfeat' branch
- merge from 'mainline'
- resolve conflicts
- run test suite, fix any errors
- commit

I point out the test-suite steps there because, after each merge,
you've got the working tree of the current branch in an untested
state. You shouldn't be committing the working tree with untested
changes.

(Previously I was doing 'pull', but as was pointed out to me, this
makes the history of the branch difficult to follow.)

> I could do it with rebase, but is there another recommended way of
> dealing with this case ?

I'd recommend against using rebase, precisely because it ignores the
requirement for testing the changes as they are applied in each
branch.

-- 
 \            “Politics is not the art of the possible. It consists in |
  `\       choosing between the disastrous and the unpalatable.” —John |
_o__)                                    Kenneth Galbraith, 1962-03-02 |
Ben Finney




More information about the bazaar mailing list