Search code examples
gitgit-cherry-pick

Cherry-pick Commit from a different repo


I was trying to cherrypick this commits

from https://github(dot)com/AICP/frameworks_base/ to https:// github(dot)com/Gopinaidu7/android_frameworks_base

I created a new branch with name master and switched to it.
I then did:

git cherry-pick 59ebfb7

and it got

fatal: bad revision '59ebfb7'

I also tried:

git cherry-pick 59ebfb7146616e57c15469d7ea85c4362c2fab3c 

and got this error

fatal: bad object 59ebfb7146616e57c15469d7ea85c4362c2fab3c.

I was doing wrong and did tried to pick those commits since last night.
I was not able to do it, can someone point me with correct commands in sequence?


Solution

  • You need to add that other repo as a remote first:

     git clone  https://github.com/Gopinaidu7/android_frameworks_base
     cd android_frameworks_base
     git remote add other https://github.com/AICP/frameworks_base
    

    Then fetch:

     git fetch other
    

    Now you can cherry-pick using the SHA1. And then push.

    If the cherry-picked commit is a merged commit:

    git cherry-pick -m 1 59ebfb7