Skip to content

Contribute as programmer

svenstaro edited this page Jul 24, 2011 · 8 revisions

We (obviously) use Git for version control and we are (also obviously) hosted here on Github, a social coding platform that allows for very easy and quick collaboration. Here is a contribution guideline:

  1. Get Git for your platform and a Github account. If you are on a Linux-based operating system, you can easily get Git it from your pacakge manager. This should be similar on OSX. On Windows, you'll want to install msysgit (guide).

  2. Have a look at the issues of one of our projects. They are tagged by difficulties "easy", "medium" and "hard". The difficulty is determined by how hard the implementation is estimated to be or by how stubborn a bug is in addition to required engine knowledge to solve the issue. If you are just starting out, take one of the easy issues and submit a comment that you are working on it. Hop onto IRC and ask us any questions you may have.

  3. Fork one of our repos on Github and clone your own fork using Git. You have full rights to make any modifications to your own fork and when you are done you can issue a pull request to us to merge your changes into the mainline branch. For example, if your Github name were foobar and you forked the ducttape-engine repo, you would use git clone git@github.com:foobar/ducttape-engine.git. This will clone your fork to a new directory called after the repo name ducttape-engine.

  4. In your clone, you should add a remote to the main repo by doing git remote add upstream git://github.com/ducttape/ducttape-engine.git. You will now have two remote as git remote will show you: one called origin and one called upstream. origin is your own fork on Github, upstream is the official repo on Github. A remote is a non-local git repo that you can pull code from. It is important to have a remote to the main development repo so you can follow new changes. If you want to pull in new changes from upstream to your current branch, simply type git pull upstream master. If you want to pull into another local branch than master, simply put its name there instead of master.

  5. Next, you should make a new branch. Your default branch is master and you shouldn't directly commit to it. Instead, you should only ever update master from the main development repo. So to make a new branch simply do git branch new-cool-feature which does the obvious, it creates a new branch called new-cool-feature as git branch will show you. To go into this branch, do git checkout new-cool-feature.

  6. This is the part where you will start hacking on the code. Keep in mind our Coding standards. Also read Nodes and Components to understand some of our most important core concepts. When you are done hacking, review your changes with git status and git diff. When you are happy with the changes, do git add file/dir to add a file or a dir to the index. The index or staging area is what you will be committing. To review your staged files, issue git status as this will tell you what you will be committing. When you are happy with that, do git commit -m "Message of what you did" which will commit your changes to the Git history.

  7. Now comes the collaboration part. As you will have noticed, your changes are not yet visible on your Github fork. You still need to push them. Use git push origin new-cool-feature which will push the local branch new-cool-feature to your own remote origin as the remote branch new-cool-feature. You can now see your changes on Github. If you are ready to discuss your changes, press the pull request button on Github while viewing your fork's new-cool-feature branch.

  8. We will then discuss your changes with you and probably suggest some changes and after a few commits we will merge your stuff. At this point, you will want to checkout your master branch again git checkout master and pull the new changes into it. git pull. Once your feature has been merged, you can safely delete the local and remote branches: git push origin :new-cool-feature git branch -d new-cool-feature

  9. Congratulations for having your changes merged and thanks for contributing!

See also