Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading