Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 282
tokenvolt Avatar asked Dec 25 '12 23:12

tokenvolt


People also ask

Can you git pull a specific commit?

How do I pull a specific commit? The short answer is: you cannot pull a specific commit from a remote. However, you may fetch new data from the remote and then use git-checkout COMMIT_ID to view the code at the COMMIT_ID .

How do you create a PR with selected commits?

There is no option to create PR with selected commits. If you want to create PR with selected commits you need to create temp branch and do git cherry-pickup commits and raise the PR with temp branch.


1 Answers

  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.

like image 59
Peter Avatar answered Oct 06 '22 00:10

Peter