当一个分支开发了两个需求A和B,其中需求A要上线,需求B不上线的时候,这个时候就需要用到cherry-pick了。使用cherry-pick的前提是有个好的提交代码习惯。需求A单独提交,需求B单独提交,不要混到一起提交。混在一起,神仙难医。

git checkout feat_AB
git log  # Find 'abcdef1',假设A的hash是abcdef1
git checkout dev
git cherry-pick abcdef1 #如果有多次提交,就多次执行就可以,顺序按提交顺序从前往后执行
# If there are conflicts, resolve them, then:
# git add <file-with-conflict>
# git cherry-pick --continue
git push origin dev

zorro
52 声望2 粉丝