跨仓库将B仓库的commit版本同步到A仓库
有两个git仓库,想把一个仓库的commit提交同步合并到另一个仓库中。使用 git cherry-pick
命令自动化同步,避免使用 cv 大法手动复制commit内容。
一. 准备一个本地的开发分支 local-dev 并切换到该分支
git checkout -b local-dev origin/local-dev
git checkout -b local-dev origin/local-dev
二. remote
新增仓库地址otherOrigin
git remote add otherOrigin <gitUrl>
三. 拉取远程otherOrigin上的所有branch的最新commit-id,将其记录
git fetch otherOrigin
四. 找到 commit 版本哈希值 commitHash,将改 commit 版本应用到该分支
git cherry-pick <commitHash>
五. 若有冲突会处在 cherry-pick
合并状态
-
放弃合并,终止合并过程