Cherry-Picking From Github

Search This thread

azoller1

Senior Member
Aug 4, 2011
1,928
1,807
My Room
OnePlus 8T
how do i cherry pick a single commit from a github source? like get a certain commit from aokps settings app and get it into cm10.1

i tried this and seemed to break my build

cd ~/android/system/frameworks/base
git fetch https://github.com/AOKP/packages_apps_Settings.git && cherry-pick 8b7e06fe63939730067b539ca7343fcd8e68ad01 FETCH_HEAD

is that the right way to do it? and how do i know if it cherry picked correctly? sorry im still getting the hang of thins with github
 

mrRobinson

Senior Member
Dec 20, 2010
2,669
12,253
how do i cherry pick a single commit from a github source? like get a certain commit from aokps settings app and get it into cm10.1

i tried this and seemed to break my build

cd ~/android/system/frameworks/base
git fetch https://github.com/AOKP/packages_apps_Settings.git && cherry-pick 8b7e06fe63939730067b539ca7343fcd8e68ad01 FETCH_HEAD

is that the right way to do it? and how do i know if it cherry picked correctly? sorry im still getting the hang of thins with github

I'd go to their gerrit. Anything and find what you want.
http://gerrit.sudoservers.com/#/q/status:open,n,z

Click on it, note the Project listed. cd to that in your tree. then in the download section you see a cherry-pick tab. click that and select the command there. That is the command you use. If it comes in without needing to merge anything you are good.
 

mrRobinson

Senior Member
Dec 20, 2010
2,669
12,253
thanks, and how would i know if merging is needed?

it'll tell you. Not sure if you use UI or command line but in command line i installed vimdiff, then set it as git mergetool with,

git config --global merge.tool vimdiff

if using UI I'd use meld.

so it'll report something needs to be merged then just
git mergetool and it'll open up. manually fix the merge
then
git status
This will show you the .orig files. delete them
Then:
git add -A
git commit -a
Control+X(nano) or :wq (vim)
And you're done.
 
  • Like
Reactions: azoller1

azoller1

Senior Member
Aug 4, 2011
1,928
1,807
My Room
OnePlus 8T
so basically just get the branch i want a cherry pick from, then picks it from the branch when i enter the commit, and i need to cd in the right directory before doing
git remote add -f repo.git?
 

Entropy512

Senior Recognized Developer
Aug 31, 2007
14,088
25,086
Owego, NY
FYI, if you are looking at a specific commit on github, you can get it in patch format by adding .patch to the URL.

For example:
https://github.com/CyanogenMod/andr...mmit/e8ba824b16a3575d9a4c5d85dce6d3800970d093
becomes
https://github.com/CyanogenMod/andr...8ba824b16a3575d9a4c5d85dce6d3800970d093.patch

If you download that .patch file, it can be applied using:
Code:
git am <patchfile>.patch

FYI, on your own machine, if you want to export such a patch for distribution, use
Code:
git format-patch
For example:
Code:
git format-patch HEAD~3
Would output the last 3 patches you committed in "git am" committable form.

FYI, this is why any developer who tells you that releasing source code for test kernels is not feasible is full of BS. It's understandable that you don't want to push test commits to a public repo, but it's perfectly feasible to meet the requirements of the GPL by providing formatted patches.

As an example: http://xdaforums.com/showpost.php?p=22925793&postcount=339
 

jaizero

Senior Member
Oct 14, 2009
382
104
44
La Crosse, WI
FYI, if you are looking at a specific commit on github, you can get it in patch format by adding .patch to the URL.

For example:
https://github.com/CyanogenMod/andr...mmit/e8ba824b16a3575d9a4c5d85dce6d3800970d093
becomes
https://github.com/CyanogenMod/andr...8ba824b16a3575d9a4c5d85dce6d3800970d093.patch

If you download that .patch file, it can be applied using:
Code:
git am <patchfile>.patch

FYI, on your own machine, if you want to export such a patch for distribution, use
Code:
git format-patch
For example:
Code:
git format-patch HEAD~3
Would output the last 3 patches you committed in "git am" committable form.

FYI, this is why any developer who tells you that releasing source code for test kernels is not feasible is full of BS. It's understandable that you don't want to push test commits to a public repo, but it's perfectly feasible to meet the requirements of the GPL by providing formatted patches.

As an example: http://xdaforums.com/showpost.php?p=22925793&postcount=339

If using this method to patch, which folder in my source do I download the patch to? Also when adding commits to my source do I need to add every single commit individually or can I just choose the commit from the major header? For example there are many commits within the Frameworks folder (Frameworks/Base..etc) do I need to go into the Frameworks folder and add each element individually or can I just add the commit from the Frameworks folder? One more thing, how to I apply a patch that I have downloaded as xxx.patch? Sorry if this is hard to understand I'm new at this and still learning the jargon.

Thanks!
 
Last edited:

molesarecoming

Inactive Recognized Developer
Feb 12, 2012
7,532
27,173
Berlin
i want this commit: https://github.com/CyanogenMod/andr...mmit/d1f1fb4064bfcef528a12a4c5176df7b44ffd48c

you need two things, the url to the main project and the commit id, both you just copy out of your browser

the branch i always use is called "jellybean"
my remote to my git is called "github"
that might differ from your configuration-

cd aosp
cd packages/app/Settings
git checkout jellybean
git remote add cyan https://github.com/CyanogenMod/android_packages_apps_Settings
git fetch cyan
git cherry-pick d1f1fb4064bfcef528a12a4c5176df7b44ffd48c


done.

in case it conflicts, you run:

grep -r "<< HEAD" .

and fix all the files it spits out. search for "<< HEAD" in these files and you should see what to do.

when you're done fixing your files you can test if it builds, if it does you go:

git add --all
git commit --all


in the end you push it up to your git

git push github jellybean
 
Last edited:

azoller1

Senior Member
Aug 4, 2011
1,928
1,807
My Room
OnePlus 8T
FYI, if you are looking at a specific commit on github, you can get it in patch format by adding .patch to the URL.

For example:
https://github.com/CyanogenMod/andr...mmit/e8ba824b16a3575d9a4c5d85dce6d3800970d093
becomes
https://github.com/CyanogenMod/andr...8ba824b16a3575d9a4c5d85dce6d3800970d093.patch

If you download that .patch file, it can be applied using:
Code:
git am <patchfile>.patch

FYI, on your own machine, if you want to export such a patch for distribution, use
Code:
git format-patch
For example:
Code:
git format-patch HEAD~3
Would output the last 3 patches you committed in "git am" committable form.

FYI, this is why any developer who tells you that releasing source code for test kernels is not feasible is full of BS. It's understandable that you don't want to push test commits to a public repo, but it's perfectly feasible to meet the requirements of the GPL by providing formatted patches.

As an example: http://xdaforums.com/showpost.php?p=22925793&postcount=339

i think this is the easiest way to pick a commit from someone and add it into your own source, but instead i used this command line in my root source

patch -p1 < ./patch

seems to fail a lot when adding the patch but its really easy to fix it
 
  • Like
Reactions: sgt. meow
FYI, if you are looking at a specific commit on github, you can get it in patch format by adding .patch to the URL.

For example:
https://github.com/CyanogenMod/andr...mmit/e8ba824b16a3575d9a4c5d85dce6d3800970d093
becomes
https://github.com/CyanogenMod/andr...8ba824b16a3575d9a4c5d85dce6d3800970d093.patch

If you download that .patch file, it can be applied using:
Code:
git am <patchfile>.patch

FYI, on your own machine, if you want to export such a patch for distribution, use
Code:
git format-patch
For example:
Code:
git format-patch HEAD~3
Would output the last 3 patches you committed in "git am" committable form.

FYI, this is why any developer who tells you that releasing source code for test kernels is not feasible is full of BS. It's understandable that you don't want to push test commits to a public repo, but it's perfectly feasible to meet the requirements of the GPL by providing formatted patches.

As an example: http://xdaforums.com/showpost.php?p=22925793&postcount=339

FYI, you use a lot of `FYI` in your post lol.

Sent from my Nexus 7 using Tapatalk 4
 

Top Liked Posts