Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Steps to accepting pull requests from open source contributors

Add contributors pull requests to your origin remote

# .git/config
[remote "origin"]
  fetch = +refs/heads/*:refs/remotes/origin/*
  fetch = +refs/pull/*/head:refs/remotes/origin/pr/*
  url = git@github.com:thoughtbot/[repo].git

Fetch and checkout the remote branch. Run bundle to make sure any new dependencies are installed.

git fetch
git checkout -t origin/pr/[pull number]
bundle

Look at changes in branch

git fetch origin; git diff origin/master

Validate tests are passing

rake

Rebase interactively and squash if there are multiple commits

git rebase -i master

Merge code into master

git checkout master

git merge branch-name

Validate tests are still passing

rake

Push code to origin master

git push origin master

Clean up branch and remote

git branch -D branch-name
@calebhearth
Copy link

calebhearth commented Oct 27, 2012

Here's some magic to add pull-requests as branches on origin that you can check out, rather than adding a remote that you have to add/remove per-contributer:

# .git/config
[remote "origin"]
  fetch = +refs/heads/*:refs/remotes/origin/*
  fetch = +refs/pull/*/head:refs/remotes/origin/pr/*
  url = git@github.com:thoughtbot/[repo].git

@harlow
Copy link
Author

harlow commented Nov 2, 2012

This is good stuff Caleb. Added to the gist.

@croaky
Copy link

croaky commented Mar 20, 2013

@harlow Maybe simplify some of these to use the hub gem?

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