|
 | Chef Project Development This page describes the workflow used for working on the Chef and related projects (Ohai, mixlibs, etc) source code. To learn more about Git itself:
To learn about working with git and cookbooks:
|
Initial setup of development repository
- Setup a github account
- Fork the repositories

- Clone the repositories locally
- Enter the chef directory and add an opscode remote
You'll be able to see if this is successful with git config:
- 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). The colon (":") tells Git to delete the specified branch.
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?
- 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.
- Do work
- Commit (see step two if more work remains)
- 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.
- Rebase your commits with the tracking-branch shortcuts (handy dandy)
- 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!
- 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:
- Remove your local branch
- Remove your remote branch by using the full syntax to 'push', and omitting a source branch.
|
|
2 Comments
comments.show.hideNov 25, 2010
Ringo De Smet
I tried removing the master branch from my forked repo (the optional step in the above process), but it always fails on me:
What am I doing wrong?
Jan 18, 2012
Mark Bate
I'm also seeing the same error. It does say it's optional though, so not a show stopper