git中如何将已commit的代码commit到其它分支

来源:互联网 发布:灵格斯for mac 编辑:程序博客网 时间:2024/05/15 17:58
目前在主分支develop上开发产品,有项目分支Branch1、BranchN,在Branch1中发现了一个bug,在此分支已经修改并commit代码,此bug也在产品主分支develop和其它分支也存在,如何将此commit的代码commit到其它分支?
     在git bash中使用git log查看bug的commit id


$ git log
commit 6314b4e0b339ff4d2b894b33d4b835c62611fff1
Author: xxx <xxx@yonyou.com>
Date:   Wed Nov 4 15:07:58 2015 +0800


例如,想将此bug也commit到develop分支,先使用git checkout develop切换至develop分支,然后使用git cherry-pick [commit id]将此bug的修改commit到当前分支

$ git cherry-pick 6314b4e0b339ff4d2b894b33d4b835c62611fff1
[develop a6746c6] commit comment
Date: Wed Nov 4 15:07:58 2015 +0800
1 file changed, 1 insertion(+)



注意:如果有冲突,需要手动解决冲突。
0 0