Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This guide is optional for contributors. It is not necessary to use GitHub to contribute patches.

Note: This content was moved over from https://wiki.apache.org/hadoop/GithubIntegration


There are several ways to setup Git for committers and contributors. Contributors can safely setup Git any way they choose but committers should take extra care since they can push new commits to the trunk at Apache and various policies there make backing out mistakes problematic. To keep the commit history clean take note of the use of --squash below when merging into apache/trunk.


Table of Contents

Git setup

...

This describes setup for one local repo and two remotes. It allows you to push the code on your machine to either your GitHub repo or to apache/hadoop GitHub repo. The ASF official repository is gitbox.apache.org, however, the repository can be writable from both GitBox and GitHub if you are a committer. You will want to fork GitHub's apache/hadoop to your own account on GitHubon GitHub, this will enable Pull Requests of your own. Cloning this fork locally will set up "origin" to point to your remote fork on GitHub on GitHub as the default remote. So if you perform `git push origin trunk` it will go to GitHubyour fork.

To attach to the Apache git repo do the following:

Code Block
git remote add apache https://gitboxgithub.com/apache.org/repos/asf/hadoop.git


To check your remote setup:

...

Code Block
origin    https://github.com/your-github-id/hadoop.git (fetch)
origin    https://github.com/your-github-id/hadoop.git (push)
apache     https https://gitboxgithub.com/apache.org/repos/asf/hadoop.git (fetch)
apache     https https://gitboxgithub.com/apache.org/repos/asf/hadoop.git (push)


Now if you want to experiment with a branch everything, by default, points to your github account because origin is the. You can work as normal using only github until you are ready to merge with the apache remote. Some conventions will integrate with Apache Jira ticket numbers.

...


Once you are ready to commit to the apache remote, you can merge and push them directly or better yet create a PR.We recommend creating new branches under feature/ to help group ongoing work, especially now that as of November 2015, forced updates are disabled on ASF branches. We hope to reinstate that ability on feature branches to aid development.

How to create a PR

...

Push your branch to GitHub:

Code Block
git checkout feature/hadoop-xxxx
git fetch apache
git rebase apache/trunk # to make it apply to the current trunk
git push origin feature/hadoop-xxxx

...

  1. Go to your feature/hadoop-xxxx branch on Github. Since you forked it from Github's apache/hadoop it will default any PR to go to apache/trunk.
  2. Click the green "Compare, review, and create pull request" button.
  3. You can edit the to and from for the PR if it isn't correct. The "base fork" should be apache/hadoop unless you are collaborating separately with one of the committers on the list. The "base" will be trunk. Don't submit a PR to one of the other branches unless you know what you are doing. The "head fork" will be your forked repo and the "compare" will be your `feature/hadoop-xxxx` branch.
  4. Click the "Create pull request" button and name the request "HADOOP-XXXX" all caps. This will connect the comments of the PR to the mailing list and Jira comments.
  5. From now on the PR lives on github's apache/hadoop repository. You use the commenting UI there.

...

How to run Jenkins precommit job for a PR

The precommit job is run automatically when opened a PR and when there is any change in your branch. If you are a committer and want to run Jenkins precommit job manually, log in to https://ci-hadoop.apache.org/job/hadoop-multibranch and run the job corresponding with the pull request ID. If there is no such job, click "Scan Repository Now" to scan the pull requests. If you are not committer, please create an empty commit on your branch.

Merging a PR (for committers)

In most cases, clicking the "Squash and merge button" is fine. Before merging the PR, the committer must check the title and the commit message, and fix them if needed. You can add "Signed-off-by", "Reviewed-by", and "Co-authored-by" when merging the commit.

When you need to commit the change locally and push them, start

How to create a PR (contributors)

...

Start with reading https://help.github.com/articles/checking-out-pull-requests-locally/.
Remember that pull requests are equivalent to a remote GitHub branch with potentially a multitude of commits. In this case it is recommended to squash remote commit history to have one commit per issue, rather than merging in a multitude of contributor's commits. In order to do that, as well as close the PR at the same time, it is recommended to use squash commits.

...