赞
踩
对于多分支的代码库,往往需要切换不同分支。那么往往需要用到以下两个操作:
git merge (合并分支所有commit)
git cherry-pick (有选择的合并其他分支的commit)
指定commit用于其他分支。命令:
git cherry-pick <commitHash>
例如:从icp3.6.0-b合并代码到icp3.6.0
查看icp3.6.0-b分支一个commitHash值
切换当前分支为icp3.6.0,执行如下命令:
git cherry-pick 6173278d...
执行git push命令,提交代码
git push
确认icp3.6.0分支代码是否合并成功
#合并a和b,尖括号内为a和b两次commit对应的hash值
git cherry-pick <hash of a> <hash of b>
# 转移a到c所有commit,不包含a
git cherry-pick a..c
#转移a到c所有commit,包含a
git cherry-pick a^..c
>git cherry-pick -h usage: git cherry-pick [<options>] <commit-ish>... or: git cherry-pick <subcommand> --quit end revert or cherry-pick sequence --continue resume revert or cherry-pick sequence --abort cancel revert or cherry-pick sequence -n, --no-commit don't automatically commit -e, --edit edit the commit message -s, --signoff add Signed-off-by: -m, --mainline <parent-number> select mainline parent --rerere-autoupdate update the index with reused conflict resolution if possible --strategy <strategy> merge strategy -X, --strategy-option <option> option for merge strategy -S, --gpg-sign[=<key-id>] GPG sign commit -x append commit name --ff allow fast-forward --allow-empty preserve initially empty commits --allow-empty-message allow commits with empty messages --keep-redundant-commits keep redundant, empty commi
如果出现冲突,首先解决冲突文件,然后执行git add .
然后执行下面的命令:
git cherry-pick --continue
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。