简体   繁体   中英

How to move certain commit to NEW branch

I have commit X and 2 commits after it. I should move only X to new branch. How can I do this?
(And my repo is in remote repo also, I don't think exactly what is it, but I won't get "detached head")
Thanks a lot

If commit X is the only commit you want to port to the new branch and the branch is new, simply start the new branch from that commit.

$ git branch newbranch COMMIT_HASH

If you want to move commit X to an existing branch and commit X doesn't necessary fit the branch history, then you can cherry-pick the commit

$ git cherry-pick COMMIT_HASH

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