Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git cherry-pick does not work

I get a strange error:

git cherry-pick a0cd8fe

fatal: bad revision 'a0cd8fe'

Why is that?

Note that the branch that a0cd8fe was merged to has been deleted. Is that why I get this error?

like image 326
leopoodle Avatar asked Jul 19 '26 03:07

leopoodle


2 Answers

That is because you don't have the remote branch (from where you want to cherry-pick) locally

Solution

git fetch origin <remote_branch>
git cherry-pick <commit_id>
like image 175
krishna chaitanya Avatar answered Jul 21 '26 20:07

krishna chaitanya


Just deleting a branch does not remove any commits. Immediately afterwards, any git command will work when given the SHA hash of a commit that was on the deleted branch. These so-called orphaned commits are eventually garbage collected after a set amount of time. From your output, it assists that this is what has happened. After garbage collection, the commit is permanently deleted.

like image 26
Code-Apprentice Avatar answered Jul 21 '26 20:07

Code-Apprentice



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!