This Confluence has been LDAP enabled, if you are an ASF Committer, please use your LDAP Credentials to login. Any problems file an INFRA jira ticket please.

Child pages
  • How to merge a Pull Request?
Skip to end of metadata
Go to start of metadata

It's important to actually 'merge' a Pull Request, and not just apply its commits to a branch (be it master or a release branch).

We cannot simply press the button on GitHub, as we only have read-only access. Instead, we merge the PR branch and then push to Apache Git, which then mirrors to GitHub.

Before you merge

  • Make sure the pull request was reviewed and tested and got 2x LGTM ("Looks Good To Me") from different community members.
  • Make sure Travis is green and the merge is clean
  • Also look at the commits. Do they need to be squashed? Are there 'merge commits' included? If so, have the author fix it and (force) push again to the PR.

Setting up the merge scripts

The first time, you need to setup the merge scripts. You can find them here in the Apache CloudStack repository.

Put the scripts in your $PATH somewhere, so you can run 'git-pr' and 'git-fwd-merge' without specifying the paths. Git will recognise this, and allow you to use 'git pr' from any directory.

Setting up the Git remotes

In order to merge a Pull Request, you need at least two remotes:

Example:

git remote -v

The names of the remotes are not important, as the script tries to detect the GitHub remote.

If your output doesn't look like this, then add a remote like this:

git remote add upstream https://git-wip-us.apache.org/repos/asf/cloudstack.git
git remote add github https://github.com/apache/cloudstack.git

Merging the Pull Request

A script was developed to make this an automated and easy process.

Running the script

git pr {pull_request_number}

Result:

 

PS: For those of you who used the 'git pr' alias developed by Rohit Yadav, you can also feed this script with the full PR url (like the alias required). This way, we made it fully backwards compatible so it should be easy to use this script instead and actually merge (instead of patch).

Check, check double check

We made the script smart, so it will prevent you from doing things that seem not OK. Still, please check the results before you proceed.

You'll have one merge commit, and the exact commits from the Pull Request. Using 'git status' you can check if the number makes sense. 

git status


Pushing to Apache Git

Final step is to push to the Apache git repo. Please check how your Apache repo is named (mine is 'upstream'). Check using 'git remote -v'

git push upstream {branch}

Final check

Your commit is pushed to Apache Git, which mirrors to github.com. It should arrive within a minute and set the PR to 'merged' state (it does this based on the commit hashes).

You should also see your commits in the list of latest commits.

  • No labels