美文网首页
git进阶 之 cherry-pick

git进阶 之 cherry-pick

作者: 诺之林 | 来源:发表于2020-05-29 17:58 被阅读0次

    定义

    • Apply the changes introduced by some existing commits

    • Given one or more existing commits, apply the change each one introduces, recording a new commit for each

    Git Documents git-cherry-pick

    效果

        a - b - c - d   Master
             \
               e - f - g   Feature
    
    git checkout master
    
    git cherry-pick f
    
        a - b - c - d - f   Master
             \
               e - f - g   Feature
    

    场景

    • For example, say a commit is accidently made to the wrong branch. You can switch to the correct branch and cherry-pick the commit to where it should belong
    Team collaboration
    
    Bug hotfixes
    
    Undoing changes and restoring lost commits
    

    Atlassian Git Cherry Pick

    使用

    # 单次提交
    git cherry-pick <commitHash>
    
    # 多次提交
    git cherry-pick <HashA> <HashB>
    
    # 区间提交 左开右闭
    git cherry-pick A..B
    
    # 区间提交 左闭右闭
    git cherry-pick A^..B 
    
    # 只更新工作区和暂存区 不产生新的提交
    git cherry-pick -n
    

    相关文章

      网友评论

          本文标题:git进阶 之 cherry-pick

          本文链接:https://www.haomeiwen.com/subject/qsdfzhtx.html