Pull in changes from a Github fork

gregghz picture gregghz · Jan 3, 2011 · Viewed 16.7k times · Source

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.

Answer

Dustin picture Dustin · Jan 3, 2011

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.