简体   繁体   English

如何将某些提交移动到NEW分支

[英]How to move certain commit to NEW branch

I have commit X and 2 commits after it. 我有X次提交,之后有2次提交。 I should move only X to new branch. 我应该只将X移到新分支。 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. 如果提交X是要移植到新分支的唯一提交,而该分支是新分支,则只需从该提交启动新分支。

$ 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 如果要将提交X移至现有分支,而提交X不一定适合分支历史记录,则可以选择该提交

$ git cherry-pick COMMIT_HASH

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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