svn合并git上游

A是git, B基于A开发, B使用svn, 如何合并A后面的小修改(比如release分支上的修复)?

下面是个大致的做法:

git svn clone B
cd B
git add remote A
git fetch A # 不需要checkout
# 获取某个范围内的commit, 并把顺序反过来, 因为git log把最新的放在最上面, 需要反一下; 放到一个文件中
git log REL7_3_12..REL7_3_13 --oneline | awk '{print $1}' | tac > 7.3.13.commits
# 先确认在正确的分支, 目标分支
# for each commit in 7.3.13.commits
git cherry-pick -x 660fcf0f67
# 可以把一大堆cherry-pick写在脚本中, 前面加上set -e, 出错手动修复, 已pick的删掉, 继续执行脚本pick
set -e
git cherry-pick -x 430f110f88
git cherry-pick -x 280fcf8867
git cherry-pick -x 770f880f69
...

git cherry-pick --help:

-x
When recording the commit, append a line that says "(cherry picked from commit ...)" to the original
commit message in order to indicate which commit this change was cherry-picked from. This is done only
for cherry picks without conflicts. Do not use this option if you are cherry-picking from your private
branch because the information is useless to the recipient. If on the other hand you are
cherry-picking between two publicly visible branches (e.g. backporting a fix to a maintenance branch
for an older release from a development branch), adding this information can be useful.

posted on   Gao科技  阅读(28)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· winform 绘制太阳,地球,月球 运作规律
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理

统计

点击右上角即可分享
微信分享提示