pull a fork commit to my fork (ignoring previous or later commits of that fork)


I created a fork of a project, and I liked a commit that one other fork did.
Anyways, I don’t want to pull its previous and later commits.
I can either work on sourcetree or git itself.

I tried pulling the commit but it seems like it’s importing all the previous commits of that commit, which is something I don’t want!


After clarification from the comments:

You have to clarify. What did you "like" about "the commit"? A commit by definition always includes all of its history. So did you like the change? Did you like the tree (snapshot)? Did you like the history (apparently not)? What do you want to copy? The change (cherry-pick)? The snapshot (checkout/read-tree)? – knittl, 13 hours ago

The history of the fork changed a lot of things that I don’t want in my project. I liked the change of one specific commit. (code that fixed a bug) Anyways, the code change in this commit was on multiple places, and I didn’t just want to copy-paste them into my project. – OtakuGamer, 13 hours ago

If you want the changes, i.e. the difference between the commit and its parent commit, use git cherry-pick

$ git remote add fork path/to/other/fork
$ git fetch fork
$ git checkout your-branch-which-want-to-have-the-changes
$ git cherry-pick commit-id-of-the-commit-in-the-fork-whose-changes-you-want-to-copy

Answered By – knittl

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published