Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
325 views
in Technique[技术] by (71.8m points)

git - Pull in changes from a Github fork

Someone forked a Github project of mine and made some changes. How can I merge the changes back in to my upstream version?

Also, is it possible to pull in just a specific commit?

What I'm looking is if there is a way to pull a specific commit instead of the entire branch.

question from:https://stackoverflow.com/questions/4581740/pull-in-changes-from-a-github-fork

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Pulling in a single commit would be a cherry-pick and would rewrite the commit ID (and mark you as the committer while retaining the author). The process is pretty straightforward, though:

git fetch git://github.com/user/project.git
git cherry-pick <SHA-COMMIT-ID>

You get the SHA from the repository log, for example:

git log --oneline

b019cc0 Check whether we have <linux/compiler.h>.
0920898 Include <linux/compiler.h> before including <linux/usbdevice_fs.h>.
cbf0ba1 Add DLT_DBUS, for raw D-Bus messages.
77ed5cd Libnl 2.x returns its own error codes, not errnos; handle that.

With git cherry-pick 0920898 you bring the respective commit to your current branch.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...