GitHub Pull Request
Github Pull Request is a way to keep the official repo clean by allowing other developers to review your patch before it gets merged into the corresponding branch. It offers a lot of benefits over the gerrithub. See Gerrit vs GitHub Pull Request for entire adv/disadvantages
Github - Initial setup:
- Clone the upstream project into a local repository
git clone https://github.com/dogtagpki/pki.git
- Create a fork of the project by clicking on the fork button:
- Now, you'll have your own copy of Forked repo in the format: https://github.com/<your Github ID>/pki
- Now add this remote to your cloned repo
git remote add personal https://github.com/<your Github ID>/pki
- Check whether you see the following output:
$ git remote -v origin https://github.com/dogtagpki/pki (fetch) origin https://github.com/dogtagpki/pki (push) personal https://github.com/SilleBille/pki.git (fetch) personal https://github.com/SilleBille/pki.git (push)
Now, you are ready to submit patches. (Read below to see how to submit a clean patch)
Travis - Enabling Travis CI for forked repo
1. Go to https://travis-ci.org/ and sign in using Github (Top right button)
2. Add the forked repository by clicking the + sign next to My Repositories.
3. Select the forked repository.
If necessary, click on Sync projects from GitHub or Sync account on the top right of the page to refresh the list of repositories.
Github - Verify Travis CI for forked repo
In your forked project, go to Settings -> Integration & services, verify that Travis CI appears under Services.
- Checkout the branch to which you want to submit patch:
# To submit patches to master: $ git checkout master # To submit patches to DOGTAG_10_5_BRANCH: $ git checkout DOGTAG_10_5_BRANCH
- Create a new dev branch (which you'll be submitting as the PR):
$ git checkout -b ticket-<number>
- Push the branch to your repo
$ git push personal ticket-<number> # ticket-<number> is the branch you created
- This will trigger a travis CI build. Check to see whether you are ready to submit a PR
- Submit a pull request from your branch
- Choose the correct to and from branch. You should see the list of commits that will form as patch. You'll see a screen similar to this:
If there is an error, you'll see something like this:
- Fill in the Commit Message and Commit Description that will appear in the official repo commit history
- Click on "Create Pull Request"
Merge and update fork
- Once your patch goes through and changes are reviewed, your patch is ready to be merged
- Click on the drop down next to "Merge"
- Use the following guideline to keep the official repo commit history CLEAN:
Create Merge Commit = Creates a new commit on top of the last commit in the official branch (Not recommended) Squash & Merge = Use when you have lot of insignificant commits (like correcting changes from reviewers). This will Squash all your commits into 1 single commit Rebase & Merge = Use when your patch is actually a combination of different patches (every commit is significant). This will copy all the commits on top of the last commit in the branch
- Once merged, Github will provide you an option to delete your branch. DELETE IT!
- Now, to keep your fork clean and in-sync with official repo do this in your local:
$ git checkout master # or the branch you want to sync $ git pull origin master # or the branch you want to sync $ git push personal master # or the branch you want to sync $ git branch -D ticket-<number> # Delete the local branch which you deleted from Github