Opscode
Home     Cookbooks     Blog     GitHub     Tickets 

Working with Git

This page describes the workflow used for working on the Chef source code. To learn more about Git itself:

Initial setup of development repository

  1. Setup a github account
  2. Fork the repositories
  3. Clone the repositories locally
  4. Add an opscode remote

    You'll be able to see if this is successful with git config:

  5. Adjust your branch to track the opscode master remote branch, by default it'll track your origin remote's master:

    Change it with the following

Optional: Delete your remote master branch

You don't need one! You should never develop on 'master', all development should be topic-based (see below)

Keeping your 'master' up-to-date!

Once all this is done, you'll be able to keep your local master up to date with the simple command:

Alternatively, you can synchronise your master from any branch with the full fetch/rebase syntax:

Using rebase pull will do a rebase instead of a merge, which will keep a linear history with no unecessary merge commits. It'll also rewind, apply and then reapply your commits at the HEAD.

Use this Rakefile to update chef, ohai and cookbooks repos (edit as needed).

Working on topic branches

So you wanna do some work?

  1. Create an appropriately named tracking branch!

    Setting a topic branch up to track opscode/master allows you to easily rebase your commits in preperation for merge.

  2. Do work
  3. Commit (see step two if more work remains)
  4. Rebase your commits against opscode/master
    With your work done in a local topic branch, you'll want to assist upstream merge by rebasing your commits. You can either do this manually with 'fetch' then 'rebase', or use the 'pull --rebase' shortcut. You may encounter merge conflicts, which you should fix and then mark as fixed with 'add', and then continue rebasing with 'rebase --continue'. At any stage, you can abort the rebase with 'rebase --abort' unlike nasty merges which'll leave files strewn everywhere.
  5. Rebase your commits with the tracking-branch shortcuts (handy dandy)
  6. Push a remote branch

Job's done!

Don't forget to send a pull request and update the ticket. Once your work has been merged by the branch maintainer, it will no longer be necessary to keep the local branch or remote branch, so you can remove them!
a

  1. Sync your local master up:

    Remove your local branch using -d to ensure that it has been merged by upstream. Branch -d will not delete a branch that is not an ancestor of your current head. From the git man page:

  2. Remove your local branch
  3. Remove your remote branch by using the full syntax to 'push', and omitting a source branch.
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

Copyright © 2009 Opscode, Inc. All Rights Reserved.