How to Contribute to a Project on GitHub
A quick how-to in contributing to an open source project hosted on GitHub. These instructions assume you've already created a GitHub account and properly set up your machine. For more details, GitHub also publishes similar instructions.
Set Up Your Repository
Fork a project by visiting its URL on GitHub and clicking the "Fork" button
Clone your fork to your local machine:
1 | git clone git@github.com:yourUsername/project-name.git |
Assign the original repository to a remote called "upstream" to retrieve updates from the original repository you forked:
1 2 | cd project-name git remote add upstream git://github.com/originalUsername/project-name.git |
Routinely pull all the “upstream” updates to your local repository:
1 | git fetch upstream |
And merge them to your forked master:
1 | git merge upstream/master |
Write Code
Create and check out a feature branch to house your edits:
1 2 | git branch branchName git checkout branchName |
This can be shortened to:
1 | git checkout -b branchName |
Make edits and commit them:
1 2 | git add someFile.js git commit -m "Your commit message." |
Push your new branch to GitHub:
1 | git push origin branchName |
Visit your forked project on GitHub and switch to your branchName branch.
Click “Pull Request” to request that your features be merged to the “upstream” master.