简体   繁体   中英

Github: Pull some commits from fork into original project

I, user1 , have a project at github. Another user2 created a fork and made three commits: A B and C .

I want to merge only commits A and B back into my project.

How to do it, that I could keep the history in github's network graph?

You can add a remote reference to the fork, create a branch on B, and merge that branch (in, for instance, master ):

git remote add fork /url/of/fork
git fetch --all
git branch tmp fork/B
git checkout master
git merge tmp

I find the merge cleaner than using git cherry-pick .

The OP Michał Sałaban preferred (in the comments ) create the branch with:

git checkout B 
git branch tmp 

I suggest to use github pull request.

GIthub pull request help: https://help.github.com/articles/using-pull-requests

How?

simple:

open a new branch from your current state

git checkout "COMMIT_B_ID"

this will result in detached HEAD

now create a new named branch

git checkout "MY_B_BRANCH"
git push origin MY_B_BRANCH

now github contains new branch with your changes. Go to github and open a pull reauest to merge the new branch with the master

This way (Pull requsest) you can see and verfiy that this is exactly what needs to be commited.

Godd Luck.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM