zoukankan      html  css  js  c++  java
  • git cherry-pick(不同分支的提交合并)

    git cherry-pick可以选择某一个分支中的一个或几个commit(s)来进行操作。例如,假设我们有个稳定版本的分支,叫v2.0,另外还有个开发版本的分支v3.0,我们不能直接把两个分支合并,这样会导致稳定版本混乱,但是又想增加一个v3.0中的功能到v2.0中,这里就可以使用cherry-pick了。


    就是对已经存在的commit 进行 再次提交;

    简单用法:

        git cherry-pick <commit id>


    注意:当执行完 cherry-pick 以后,将会 生成一个新的提交;这个新的提交的哈希值和原来的不同,但标识名 一样;

    例如:
    $ git checkout old_cc
    $ git cherry-pick 38361a68    # 这个 38361a68 号码,位于:
     

        $ git log

        commit 38361a68138140827b31b72f8bbfd88b3705d77a
        Author: Siwei Shen <siwei.shen@focusbeijing.com>
        Date:   Sat Dec 10 00:09:44 2011 +0800


    1. 如果顺利,就会正常提交。结果:

        Finished one cherry-pick.
        # On branch old_cc
        # Your branch is ahead of 'origin/old_cc' by 3 commits.


    2. 如果在cherry-pick 的过程中出现了冲突

        Automatic cherry-pick failed.  After resolving the conflicts,
        mark the corrected paths with 'git add <paths>' or 'git rm <paths>'
        and commit the result with:

                git commit -c 15a2b6c61927e5aed6718de89ad9dafba939a90b


    就跟普通的冲突一样,手工解决:
    2.1 $ git status    # 看哪些文件出现冲突

        both modified:      app/models/user.rb


    2.2 $ vim app/models/user.rb  # 手动解决它。
    2.3 $ git add app/models/user.rb

    2.4 git commit -c <新的commit号码>


    ---------------------
    作者:wh_19910525
    来源:CSDN
    原文:https://blog.csdn.net/wh_19910525/article/details/7554430
    版权声明:本文为博主原创文章,转载请附上博文链接!

  • 相关阅读:
    ubuntu 14.04 安装gvim 后报出warning
    ubuntu 如何搭建svn 服务器
    如何为wordpress 添加favicon
    如何为wordpress 的文章添加分页
    ubuntu 如何添加alias
    wordpress 如何防止盗链
    ubuntu 14.04 如何设置静态ip
    钉钉与金蝶ERP对接开发方式
    金蝶组件无法正常工作
    金蝶补丁安装失败
  • 原文地址:https://www.cnblogs.com/-colin/p/11057044.html
Copyright © 2011-2022 走看看