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.
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.
Create a new branch starting from the latest commit, which is also in the origin repository:
git branch new-branch origin/master
git checkout new-branch
Then use git cherry-pick
to get the single commit you want the pull request for. If the branch with this commit is called feature
and the commit you want is the latest commit in this branch, this will be
git cherry-pick feature
Assuming this patch applies without conflict, you got now a branch for which you can do your pull request.
In a second step, you now need to decide what to do with your feature
branch. If you haven't published your changes on this branch yet, the best procedure is probably rebasing this branch upon new-branch (and removing the last commit, if this is not done automatically by git rebase
).
I ended up in a situation where I had forked a fork and wanted to submit a pull request back to the original project.
I had:
To do this, I:
The git commands were something like:
Then I picked my-feature-request as the branch for my pull request to the original project.
链接地址: http://www.djcxy.com/p/45184.html