This document describes a workflow for contributing to projects that have a protected
master branch. The contribution process involves making an edit, creating a new branch, creating a pull request, merging the pull request, and then deleting the branch you created. Follow the steps below to make a contribution.
Step By Step
Make Your Edits
- Browse the project and use the pencil icon to edit a file like you normally would.
- On the edit page, make whatever changes you would like.
- At the bottom of the screen, you will be unable to commit your changes to the
masterbranch since it is protected. Instead, type in a short descriptive name to create a new branch. Like this:
- Click Commit Changes to save your work.
- If you have multiple changes to make at the same time, you can put them all on the same branch. Just make sure that you are browsing the branch you just made by verifying the branch name in the branch drop down. For example,
- Then you may click the pencil icon like normal to make another edit and you’ll see in the Commit Changes box that your in progress branch is already selected, like this:
- Once you are finished with your changes, create a Pull Request.
Create a Pull Request
Once your changes have been made you can create a pull request to merge them into the
master branch. Follow these steps.
Under the name of you project, click the “Pull Requests” button that has a number next to it.
Now click the green “New Pull Request” button in the upper right.
In the left hand box make sure that it says “base: master”. In the right hand box, select the branch you just created. As an example:
Give your pull request a title in the title box.
Fill out the description box under “Write” to provide others a description of the changes you are suggesting.
Click the green “Create Pull Request” button.
Merge the Pull Request
In this step, usually someone else on the project should be the person to merge the pull request into the
master branch. This may include some discussion or changes to your initial edits, which can be made directly on the new branch you created.
When the pull request is approved, it should be merged by clicking the green “Merge Pull Request” button,
The final step is to delete the branch that you initially made for the edits. Whoever merged the pull request should have the option to do this after the branch has been merged. For example,
Click Yes on the warning dialog that pops up. Note that because the branch has already been merged into
master, there is no data loss in this operation.