The following are some personal notes on the basic workflow for contributing to a project on Github.
- Visit the project's repo page (https://github.com/someguy/nice_project), click on "Fork" in the upper right corner.
- Clone your newly forked repo to your local machine
- Set an "upstream" remote so you can pull down "someguy"s code whenever you need to.
- Create a branch of the master or dev or whatever so you can start making your changes. Give it a meaningful name:
- Make your changes, add the files and make a commit:
- Push your changes to your forked repo. Typically known as the 'origin' remote:
- Log into Github and you should see a notification on your forked repo
- Click on the "Compare & pull request"
- Fill out the pull request, and then hit "Create pull request"
- Now you just wait on comments, requests, ridicule, or anything else. Once they are happy with your contributions they will "merge" your changes into their branch.
- Once its accepted you can delete that branch either through the Github website or at the CLI:
- Now you can pull down the updated upstream to see your changes in someguy's repo:
- If you'd like you can update your GH repo by pushing what you recently pulled down:
git clone https://github.com/you/nice_project
git remote set-url upstream https://github.com/someguy/nice_project
git branch bugFix-UTFencoding git checkout bugFix-UTFencoding #or all in one with: git checkout -b bugFix-UTFencoding
git add lib/some_file git commit -m 'fixed the UTF encoding errors'
git push origin bugFix-UTFencoding
git checkout master #it complains if you try to delete a branch you are on git branch -D bugFix-UTFencoding
git pull upstream master
git push origin master
Congrats on getting your pull request accepted and contributing to something. You will now feel slightly less like a leech.
Rinse and repeat lines 4-10 on the same project or the whole thing for a new project.
Bonus: If you want to pull down a specific branch from a remote upstream, you can easily do it with "git checkout -b up-master upstream/master"