30

Let's say I have cloned repository, created new branch "Topic1", made changes, commited them and then pushed them to a remote repo git push origin Topic1. After that I made a pull request into master branch.

Then on my local repository I checkout from branch "Topic1" to branch "Topic2", made some changes there, commited and again pushed this new branch to remote. And again made a pull request into master. I want to mention that in the meantime no changes were made to master branch, so I didn't need to sync my local repo with upstream.

And here's the problem: when I go to pull request page of "Topic2" all the commits of "Topic1" are presented there. So, my question - how can I get in 2nd pull request commits related only to "Topic2" branch?

Nevik Rehnel
  • 49,633
  • 6
  • 60
  • 50
tokenvolt
  • 1,494
  • 2
  • 14
  • 14
  • Related: Some good details on [how the pull requests are different](https://stackoverflow.com/q/6235379/465053) in Git (the software) and GitHub (the web service) – RBT Aug 12 '17 at 03:21
  • Does this answer your question? [How to "pull request" a specific commit](https://stackoverflow.com/questions/34027850/how-to-pull-request-a-specific-commit) – Michael Freidgeim Aug 18 '20 at 21:17

1 Answers1

36
  1. Create a new branch based on upstream/master

  2. cherry-pick the relevant commits from your branch Topic2 (into the new branch)

  3. Create a pull request from this new branch.

Starx
  • 77,474
  • 47
  • 185
  • 261
Peter
  • 3,916
  • 1
  • 22
  • 43
  • 1
    The problem is that I need all the changes made in Topic1 branch to be in Topic2, which not currently yet in master branch. But I don't want them to be displayed in pull request related to Topic2 branch. – tokenvolt Dec 25 '12 at 23:52
  • 1
    Thats not possible. Pull requests include all changes in comparison to the target branch. But you could have 3 branches: one as your "working branch" with merged commits from Topic1 and Topic2 and the two other branches just for the pull requests. – Peter Dec 25 '12 at 23:59