Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Merge in GitHub pull requests, possibly making changes to them first

Tags:

I recently started managing a project on GitHub where people have been submitting pull requests. Rather than merge them to master, I would like the ability to:

  1. First vet them to make sure they actually work

  2. Possibly making some stylistic changes before merging to master

How can I do this?

Do you have to make a separate branch, such as "dev", and instruct people to code against that before you merge to master?

like image 765
Jeff Avatar asked Jun 25 '11 00:06

Jeff


People also ask

What happens when I merge a pull request in GitHub?

When you select the Squash and merge option on a pull request on GitHub.com, the pull request's commits are squashed into a single commit. Instead of seeing all of a contributor's individual commits from a topic branch, the commits are combined into one commit and merged into the default branch.

What happens when a pull request is merged?

Merging occurs once a developer's submitted pull request has been approved by the repository maintainer. Before merging, the repository maintainer will need to review the developer's completed work. They will comment on any issues, and request edits from the developer as needed.

How do you merge changes from a pull request?

To accept the pull request, click the Pull Requests tab to see a summary of pending pull requests. If you are happy with the changes, click Merge Pull request to accept the pull request and perform the merge. You can add in a comment if you want. Once you click Merge Pull request, you will see a button Confirm merge.

Can you make changes to a pull request?

To edit a pull request, select the pull request on the Pull requests page, go to its detail page and click "Edit". The target branch (the base branch) and the pull request branch (the branch that will be merged) cannot be changed.


2 Answers

There is a github help page on this which details how to make changes to a pull request by checking out pull requests locally.

What I might try is first creating a remote for the pull request submitter (I'm using the examples from the above page):

git remote add kneath git://github.com/kneath/jobs.git 

Fetch the changes:

git fetch kneath 

Check out the branch in question (ex. master):

git checkout kneath/master 

Vet them however you like, since the code that will be there will be the pull request code. Run tests, etc.

Merge them in if you're good to go:

git checkout master git merge kneath/master 

Further, here is a very good page on git project management workflows which details the various workflows one can take on collaboration integration.

like image 165
Jorge Israel Peña Avatar answered Sep 29 '22 08:09

Jorge Israel Peña


A faster way of doing things with GitHub is to use this GitHub feature presented by Zach Holman in his GitHub Secrets II Talk (video).

git fetch origin pull/id/head:name 

Where id is the pull request id, head is the remote branch (on the fork), and name is the name you want to give the local branch. For example:

git fetch origin pull/12/head:pr 

Fetches pull request #12 into a branch named pr.

You can add this as an alias in git if you use this a lot.

like image 44
Alex Avatar answered Sep 29 '22 08:09

Alex