3

Let's say I am working on my master in my own repository. My upstream for example is main-upstream.

But I need one specific commit from another remote - special-upstream. I don't want another changes from it - I do not need all commits from that remote and I don't want any changes from it - it's a different project - except one certain commit with certain hash from branch master.

Is it possible to cherry-pick it?

lapots
  • 12,553
  • 32
  • 121
  • 242

2 Answers2

5

Add the other repo as a remote and fetch it's commits:

git remote add otherremote <url to other remote>
git fetch otherremote

Cherry pick the commit from the other repo

git cherry-pick <sha1 from otherremote>

This will cherry-pick the selected commit into the current branch.

joran
  • 2,815
  • 16
  • 18
0

Yes. git fetch the remote, then git checkout master ; git cherry-pick <commit>. Same as usual. As long as you only git fetch and not git pull or git checkout special-upstream/xyz, you will not "pollute" your own repository with anything else.

AnoE
  • 8,048
  • 1
  • 21
  • 36