Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git cherry-pick branchless commit on remote

Tags:

git

github

I'm trying to cherry pick a commit from github.

https://github.com/angular/angular.js/commit/469b750019adb193f2b973ab841ac87d0d06d4f2

As far as I can tell, it isn't a part of any active branches. I tried this in my local repo:

git remote add upstream https://github.com/angular/angular.js.git
git fetch upstream
git cherry-pick 469b750

I get this error

fatal: bad revision '469b750'

Is what I'm trying to do possible? I searched for lost, orphaned, and branchless commits, but I didn't find anything that helped. I could just copy/paste this and be done with it, but I'm trying to keep the history and learn more about git. Thank you.

like image 622
Chad von Nau Avatar asked Oct 18 '14 22:10

Chad von Nau


2 Answers

It will not be exactly cherry pick, but you can apply this commit as follows:

  1. Add .patch to Github URL and save it as git patch file:

    wget https://github.com/angular/angular.js/commit/469b750019adb193f2b973ab841ac87d0d06d4f2.patch -o new.patch
    
  2. Apply this commit to your tree with git am:

    git am new.patch
    

Outcome of this should be identical to cherry-picking.

like image 92
mvp Avatar answered Nov 14 '22 01:11

mvp


That's a really interesting problem. I was testing it locally myself and the commit doesn't appear in reflog --all so it is not only orphaned but it's not downloaded from Github on a pull, clone or fetch. It may be a case that it's totally lost forever unless you download it manually and put it back in the tree.

https://help.github.com/articles/commit-exists-on-github-but-not-in-my-local-clone/

like image 23
BookOfGreg Avatar answered Nov 14 '22 01:11

BookOfGreg