Last Updated: November 19, 2020
·
117.4K
· jodosha

Git cherry-pick from another repository

Let's say you want to apply some patches from someone else repository:

# Cloning our fork
$ git clone git clone git@github.com:ifad/rest-client.git

# Adding (as "endel") the repo from we want to cherry-pick
$ git remote add endel git://github.com/endel/rest-client.git

# Fetch their branches
$ git fetch endel

# List their commits
$ git log endel/master

# Cherry-pick the commit we need
$ git cherry-pick 97fedac

# Pushing to our master
$ git push origin master

Related protips:

git checkout remote branch

3 Responses
Add your response

Or light version:
git fetch <remote-git-url> <branch> && git cherry-pick SHA1

For example:
git fetch https://github.com/antonbabenko/imagepush2 && git cherry-pick 20258def3280b4ccba286c4a021140c66292ebc0

over 1 year ago ·

Simple & great

over 1 year ago ·

Thank you for your tip!

some trivial errors
1. git clone git clone git@github.com:ifad/rest-client.git => git clone git@github.com:ifad/rest-client.git
2. git remote add endel git://github.com/endel/rest-client.git => git remote add endel https://github.com/endel/rest-client.git

over 1 year ago ·