简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM