Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Send a pull request on GitHub for only latest commit

I forked a project on github and am successfully making changes to my local master and pushing to origin on github. I want to send a pull request, but only want to include the last commit. The pull request UI on github.com shows the last 9 commits and I don't know how to filter that down.

I was trying to understand if I should create a new local branch, check that out and somehow reset or rebase to upstream? Then apply my last commit from my master by id to the new local branch and use that for the pull request?

I'm trying to get the concepts right and figure out the right command lines to do what I need.

like image 872
Kevin Hakanson Avatar asked Mar 10 '11 05:03

Kevin Hakanson


People also ask

How do I create a pull request only for a specific commit?

Go to either the git log or the GitHub UI and grab the unique commit hashes for each of the commits that you want. "Cherry pick" the commits you want into this branch. Run this command: git cherry-pick super-long-hash-here . That will pull just this commit into your current branch.

How do you git pull upto 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 .


1 Answers

You need to basically create a new branch & cherry-pick the commits you want to add to it.

Note: you might need these before the checkout/cherry-pick commands

git remote add upstream <git repository>

git remote update

git checkout -b <new-branch-name> upstream/master  git cherry-pick <SHA hash of commit>  git push origin <new-branch-name> 

Afterwards, you will see <new-branch-name> branch on github, switch to it and can submit the pull request with the changes you want.

like image 154
Kevin Hakanson Avatar answered Oct 14 '22 12:10

Kevin Hakanson