tokenvolt tokenvolt - 1 year ago 163
Git Question

Include only specific commits in a pull request

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?

Answer Source
  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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download