3

I have been struggling a lot in creating a pull request for a single commit. I have followed this SO link (command line), but still after creating the new branch i am seeing 9 unwanted commits in my pull request with the one i want. I want to create a request for only single commit.

Is this possible through interface OR if any other way to create single commit pull request

Community
  • 1
  • 1
AnkitG
  • 6,438
  • 7
  • 44
  • 72
  • 2
    I think it is because you have different histories and possible a merge from something else. You should branch from the upstream branch to which you are creating the pull request and cherry-pick the commit you want. – kan Jul 08 '13 at 19:20
  • well i am trying to do same, my upstream branch in master and i create a branch. But when i push that branch and try to do a pull request it is listing other commits too.. – AnkitG Jul 08 '13 at 19:25
  • In that case dont do pull request do git fetch and then merge the commit that you want manually. – uday Jul 08 '13 at 19:30

1 Answers1

4

Your branches have diverged, and it's impossible to simply drag the top commit off the other branch with a pull request. What you need is a cherry pick: Check out the remote branch, create a new branch from that state, and then cherry pick your single commit onto the new branch. Then you can issue a pull request for the new branch.

user229044
  • 232,980
  • 40
  • 330
  • 338
  • Master is my current branch, i created a new branch out of master and cherry-picked my commit and pushed my branch to github.com. It still shows all commits with the one i wanted in pull request :( – AnkitG Jul 08 '13 at 19:55
  • What branch are you trying to merge your changes into? – user229044 Jul 08 '13 at 20:07
  • The branch where i had my commit was a different branch, i merged it onto my master. Now i am trying to create pull request from my master – AnkitG Jul 08 '13 at 20:11
  • You can't base your new branch of *your master*. You need to check out the branch you're issuing a pull request into, and cherry pick onto that branch. – user229044 Jul 08 '13 at 20:15
  • Ok, i did a git checkout origin/mybranch (this is the branch i pushed the commit). Now i created a new branch out of it and cherry picked the commit. I pushed it again and it same.. i am sorry for this – AnkitG Jul 08 '13 at 20:39