git cherry-pick挑选合入远程仓库的commit

问题背景

以开源仓库atdt/monotonic为例,这里我fork了一个自己的仓库tongyishu/monotonic。开源atdt/monotonic仓库的master分支上有一个commit,我想要合并到自己fork仓库的dev分支:

remote仓库:atdt/monotonic
remote分支:master
remote链接:https://github.com/atdt/monotonic.git

fork仓库:tongyishu/monotonic
fork分支:dev
fork链接:https://github.com/tongyishu/monotonic.git

操作步骤

1)clone自己fork的远程仓库,并切换到对应的分支

git clone https://github.com/tongyishu/monotonic.git
git checkout dev

2)添加远程仓库,并拉取代码

git remote add monotonic https://github.com/atdt/monotonic.git
git fetch monotonic
git remote -v // 此时有两个远程仓库:monotonic为atdt/monotonic,origin为tongyishu/monotonic

3)切换远程仓库的分支,想找要cherry-pick的commit,这里为58160d03e9536d8a91c5d3abede7a1947607fcb6

git checkout monotonic/master
git log

4)找到commit点后,切换到fork的dev分支,执行cherry-pick即可

git checkout dev
git cherry-pick 58160d03e9536d8a91c5d3abede7a1947607fcb6
git log // 此时可以看到commit已经同步到dev分支了

展开阅读全文

页面更新:2024-02-24

标签:仓库   分支   背景   代码   链接

1 2 3 4 5

上滑加载更多 ↓
推荐阅读:
友情链接:
更多:

本站资料均由网友自行发布提供,仅用于学习交流。如有版权问题,请与我联系,QQ:4156828  

© CopyRight 2020-2024 All Rights Reserved. Powered By 71396.com 闽ICP备11008920号-4
闽公网安备35020302034903号

Top