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!
CodePudding user response:
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