Skip to content

Instantly share code, notes, and snippets.

@epwalsh
Last active February 22, 2019 18:10
Show Gist options
  • Save epwalsh/9e1b77d46ec232d55e6e344bb649fb19 to your computer and use it in GitHub Desktop.
Save epwalsh/9e1b77d46ec232d55e6e344bb649fb19 to your computer and use it in GitHub Desktop.
How to make a PR to an open source project without pissing everyone off

Initial setup

Step 1: Fork the repo.

Step 2: Clone your fork locally.

git clone https://github.com/USERNAME/REPO.git

Or

git@github.com:USERNAME/REPO.git

if you want to clone using SSH.

NOTE: Replace USERNAME with YOUR GitHub username and REPO with the name of the repo.

Step 3: Set the upstream remote to the original repo.

This step is essential if you plan on contributing regularly, as it let's you easily pull new commits from the original repo into your fork.

git remote add upstream https://github.com/ORGANIZATION/REPO.git

NOTE: ORGANIZATION should be set to the username/organization name of the ORIGINAL repo.

PR workflow

Step 1: Pull recent updates from the original repo.

git checkout master  # if not already on master
git pull --rebase upstream master
git push

Now if you visit your fork of the project on GitHub, it should say that your master branch is up-to-date with the original master branch.

Step 2: Create a new branch to work on your fix/improvement/feature.

git checkout -b BRANCH

Step 3: Write some awesome, well-documented code.

(Too bad there's not a git command for that)

Step 4: Create the PR.

Depending on who the admins are and what they expect, you may also want to rebase your commits. But this usually isn't necessary since the admins can always squash commits when they merge the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment