-
Notifications
You must be signed in to change notification settings - Fork 14
Contributing to the repository
- Make sure you're on the master branch.
git branch -l
If not, switch to the master branch.git checkout master
- Pull the latest updates from master
git pull origin master
- Create a new branch named after the feature that you're implementing
git checkout -b "my_new_feature"
- Make the necessary changes, making sure to regularly commit with good commit messages.
- Push the changes to github
git push origin my_new_feature
-
After pushing, check the main github page of the project and there should be an option to create a pull request from your recently pushed branch.
-
Make the pull request and give a brief description. If the pull request addresses an open issue (say, issue 4), add the text
closes #4
to the body of the request, so that merging the pull request will also close the issue. -
Let others to review and approve the pull request. This may require you to make new commits to the branch, which can be added to the pull request with
git push origin my_new_feature
. Eventually, the reviewer approves the changes (commenting on the pull request). -
If your branch is clear to merge, there should be a big green button on the bottom of the page that lets you merge. You might have some merge conflicts, however, in which case the merge button will be red. To resolve this, get the latest changes on master (
git pull origin master
), then rungit rebase master
from your feature branch, resolve all conflicts, add conflicted files withgit add
, and continue the rebase withgit rebase --continue
. -
Now, squash your changes into a single commit to keep the log clean. To do this, run
git rebase -i HEAD~n
, where n is the number of commits on your branch. This will give you an interactive editor, wherein you should leave the first (top-most, i.e. earliest) commit as 'pick', and change all subsequent commits to 'squash'. Save and exit, and you will be presented with another editor in which you can specify a commit message for all of your work. -
Now push this change with
git push -f origin my_new_feature
. -
Now you're ready to merge! If you don't get a green button that says you can merge, you've done something terribly wrong. Otherwise, merge with:
git checkout master git merge my_new_feature git push origin master
and subsequently reload your pull request page (which should now say that it's merged) and push the "delete this branch" button to remove your remote feature branch.
-
Your local repo doesn't know that the remote branch has been deleted, so clean up state with:
git checkout master git pull --prune origin git branch --merged | grep -v "\*" | xargs -n 1 git branch -d
-
All done!