问题
I'm new to git, so forgive me for any mistakes I make with my terminology.
I have a forked repo. In the origin repo, someone makes a pull request containing a bunch of different commits. That pull request is then merged into the origin. I would also like that pull request, so I want it merged into my repo too. What's the correct way of doing this? I tried cherry-picking each commit, and that worked, but I feel like that isn't the right way to get things done.
Edit: I'll attempt to more specific about exact structure of what's happening and what I want to do.
There is the original repo we'll call A.
A group of developers forked that repo into a mostly separate project that we'll call B.
I forked B so that I could create my own branches and contribute with pull requests, this is repo C.
There's a change to repo A through a pull request. This PR was made after the fork that created B, and we want the commits from A's PR in repo B.
In order to add it to B, I need to do the same merge they did to A, and do it on my repo C, then make a pull request for B with the changes.
Right now, rather than merge the PR commits from A into C, I instead just cherry picked the commits from the PR and applied them in order. This worked, but I don't feel like this is the best way to do things.
回答1:
Check out the branch you wish to merge to on your fork. Usually, you will merge into master.
git checkout master
Pull the desired branch from the upstream repository. This method will retain the commit history without modification.
git pull https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git BRANCH_NAME
If there are conflicts, resolve them. For more information, see "Addressing merge conflicts".
Commit the merge.
Push the merge to your GitHub repository.
git push origin master
来源:https://stackoverflow.com/questions/48289101/merge-pull-request-from-upstream-branch-into-a-forked-repository