网站首页 > 精选文章 正文
问题背景
以开源仓库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分支了
猜你喜欢
- 2025-01-20 将 node_modules 目录放入 Git 仓库的优点
- 2025-01-20 微软开源Scalar 提升操作巨型Git仓库的速度
- 2025-01-20 把一个 Git 仓库打包成 zip 压缩包
- 2025-01-20 不同主机迁移git仓库Gitolite
- 2025-01-20 同步GIT仓库的操作 -- fetch命令
- 2025-01-20 git log 命令用法实例 (2)
- 2025-01-20 还在为 Git 仓库瘦身头疼?快来试试 repo-clean
- 2025-01-20 自建Git服务器 - 创建属于你自己的代码仓库,开启你的Git私服之旅
- 2025-01-20 中央仓库管理-基于工作空间和git-submodule实现共用和管理
- 2025-01-20 从零开始,小白也能学会的创建Git仓库实操
- 最近发表
- 标签列表
-
- 向日葵无法连接服务器 (32)
- git.exe (33)
- vscode更新 (34)
- dev c (33)
- git ignore命令 (32)
- gitlab提交代码步骤 (37)
- java update (36)
- vue debug (34)
- vue blur (32)
- vscode导入vue项目 (33)
- vue chart (32)
- vue cms (32)
- 大雅数据库 (34)
- 技术迭代 (37)
- 同一局域网 (33)
- github拒绝连接 (33)
- vscode php插件 (32)
- vue注释快捷键 (32)
- linux ssr (33)
- 微端服务器 (35)
- 导航猫 (32)
- 获取当前时间年月日 (33)
- stp软件 (33)
- http下载文件 (33)
- linux bt下载 (33)