After deletion of a local branch in git, will I be able to cherry-pick commits from the deleted branch by their IDs?

If I have a local branch in git with commits A, B, C, D, E and I choose to delete it using

git branch -D myBranch

but I save the commit IDs before deleting, will I be able to cherry-pick some of these commits to another branch by their IDs afterwards?

>Solution :

Yes. Just specify the commit ids (SHAs) in the cherry-pick command:

git cherry-pick -x <commit-hash>

(The -x is not required, but recommended as it will give you a standard comment.)
This answer has more details.

Leave a Reply