5

Someone has submitted a pull request to my GitHub project from a fork. Rather than merging directly into master, I would prefer to merge the changes into a feature branch so that I can make some minor edits before merging the final product into master. If at all possible, I'd like GitHub to indicate to the submitter that the request was accepted (I want to encourage and recognize contributions!). Is this possible? How do I go about it?

ChaseMedallion
  • 20,860
  • 17
  • 88
  • 152
  • 1
    I'm not sure you can acknowledge the contribution through GitHub. I think you have to just manually comment on the PR and thank the contributor. About the feature branch, just add the fork as another remote in your local repository and merge the remote branch into your feature branch. – whatyouhide Jan 31 '15 at 17:44

4 Answers4

4

Firstly you should create a copy of the branch that the pull-request is targeting. After that you can change the branch by editing the Pull-Request that was opened (even if it was not opened by you) by clicking the edit button (See the images below). Once you have done that you should double-check if the target branch was changed.

If it changed successfully then you can merge the PR into the new branch.

Edit button location

Branch selection when clicking the edit button

Changed target branch

GHXX
  • 86
  • 1
  • 7
2

This is possible! First create a feature branch:

$ git checkout -b my-feature

Then pull and merge the pull request's changes to your new feature branch:

$ git pull https://github.com/user/fork.git

Make your minor adjustments in a new commit:

$ # make changes
$ git commit -am "my minor changes"

Then merge your feature branch into master and push to github.

$ git checkout master
$ git merge my-feature
$ git push origin master

This will be reflected on the pull request on github.com, and you can leave a comment thanking the submitter if you like.

jshawl
  • 3,315
  • 2
  • 22
  • 34
  • Also can be done via the Github UI now. [See this answer](https://stackoverflow.com/a/38985999/3681279). – sloreti Apr 28 '21 at 17:15
0

I recently had to accept a contributor's PR and I followed the below process:

git fetch <fork-url> <PR-branch name>

The above command should give you a FETCH_HEAD (which is a short-lived reference to keep track of what has just been fetched from the remote repository)

Now create a branch out of this FETCH_HEAD as a 'start point'

git checkout -b my-feature-branch FETCH_HEAD

Now since you got the local branch, you can do the usual stuff like re-base, merge etc.

Once you merged this branch with master and pushed it, I would put in the commit hash the on contributor's PR and thank him :-)

Kiran
  • 56,921
  • 15
  • 176
  • 161
0
Simple Steps :-

 //checkout main
git checkout main

//pull all latest changes
git pull --rebase

//checkout a tempLocal branch
git checkout -b tempLocal

//check all remote branches (will also show PR branches)
git branch -v -a

//lets assume our branch name is remotes/origin/usr/adam/feature1

//Pull that selected branch inside tempLocal
git pull origin usr/adam/feature1
Sumer
  • 2,687
  • 24
  • 24