How to do Pull Requests in GitHub


This is a brief discussion on one way you can setup your workspace to use Pull Requests in GitHub. This is the current method the Directory Server development uses, and to make it easier to contribute it would be best to use this same approach.

Setup Your Workspace

You must first create a fork of the project, then you will clone the main repo, and add your fork to it. Then initialize your new fork with master branch (this is a one time task for setting up the fork for the first time).

$ git clone
$ cd 389-ds-base
$ git checkout master
$ git pull
$ git remote add myfork
$ git push myfork --force

Work On A New Fix

You will create a new branch under the master branch. Make changes and commit them as usual. When you are done you will need to push your new branch to your fork.

$ git checkout master
$ git pull
$ git checkout -b issue9999
$ git commit -a -m "My Fix!"
$ git push myfork

Then file a pull-request in GitHub, You will see this branch (issue9999) in the GitHub UI. Then send out a “please review” email to 389-devel mailing list

Amending A Fix

So to make changes to a PR go to your branch, make changes, and commit them. Then you MUST do forced push to your fork which will automatically update the PR.

$ git checkout i9999
$ <make source changes>
$ git commit -a --amend
$ git push myfork --force

Merging Your PR

Once you gets your acks or LGTM (Looks Good To Me), then rebase your branch with master again, in case someone else pushed a patch, and then push the branch to your fork again.

$ git checkout master
$ git pull
$ git checkout i9999
$ git rebase master
$ git push myfork --force

Now the PR can be merged using the GitHub UI.

That’s it!

Cherry Picking

Often most fixes need to be present in several branches. We only use PR’s for commits to master, but for 389-ds-base-1.4.4, etc, we manaully cherry pick these fixes. So after the fix is in master, you will need do the following:

$ git checkout master
$ git pull origin master
$ git checkout 389-ds-base-1.4.4
$ git cherry-pick master
$ git push origin 389-ds-base-1.4.4

$ git checkout 389-ds-base-1.4.3
$ git pull origin 389-ds-base-1.4.3
$ git cherry-pick 389-ds-base-1.4.4
$ git push origin 389-ds-base-1.4.3

Last modified on 30 April 2021