Home > Net >  How can I merge just the first commit of a pull request?
How can I merge just the first commit of a pull request?

Time:02-19

My Github repository has received a pull request consisting of several commits. I only want to accept the first of these. Is there any way I can do this without asking the PR author to change their PR?

The PR was sent a long time ago and I've been unable to reach the author. I realise that I could just create a new commit myself, but I'd prefer to have the original commit author's name on the commit.

CodePudding user response:

I'd prefer to have the original commit author's name on the commit.

Nice and polite!

The first approach: create a commit and artificially assign it to a different author using git commit --author=<author>. You can even change author's date to the date of the commit at GH: --date=<date>.

The second approach is: fetch the PR from GH to a local branch and merge/cherry-pick one commit from the branch:

git fetch origin pull/$ID/head:pr-$ID # fetch the PR into branch pr-$ID
git log pr-$ID # view commits and find the one
git merge $COMMIT_ID

PS. Next time please use search.

  • Related