归并多次commit记载

打印 上一主题 下一主题

主题 865|帖子 865|积分 2595

1. 起首先提交多次记载

在log中可以看到有多次commit 记载
然后拉取最新代码
  1. (base) ➜  gaolijie git:(master) git pull --rebase origin master
  2. From https://gitee.com/Blue_Pepsi_Cola/gaolijie
  3. * branch            master     -> FETCH_HEAD
  4. Already up to date.
复制代码
执行归并代码
  1. (base) ➜  gaolijie git:(master) git rebase -i HEAD~3
复制代码
执行了 rebase 之后会弹出一个窗口,让你选择归并哪些 commit 记载
  1. pick 3ca6ec3   '注释**********'
  2. pick 1b40566   '注释*********'
  3. pick 53f244a   '注释**********'
复制代码
需要把 pick 改为 s 或 squash,需要留第一个,第一个不要改,意思是下面的 commit 记载都归并到第一个上面去。
  1. pick 3ca6ec3   '注释**********'
  2. s 1b40566   '注释*********'
  3. s 53f244a   '注释**********'
复制代码
生存退出
如果有冲突,可以先解决冲突,解决完之后执行:
  1. git add .
  2. git rebase --continue
复制代码
如果没有冲突,或者冲突已经解决,会弹出窗口,让你注释掉一些提交记载,这里是让我们编辑自己归并的这些记载的概览,如:完成了什么功能,按照实际情况填写。
  1. # This is a combination of 3 commits.
  2. # This is the 1st commit message:
  3. 这里是填写最新的commit
  4. #fix: 5
  5. # This is the commit message #2:
  6. #fix: 6
  7. # This is the commit message #3:
  8. #合并fix7 8 9
  9. # Please enter the commit message for your changes. Lines starting
  10. # with '#' will be ignored, and an empty message aborts the commit.
  11. #
  12. # Date:      Sun Feb 16 18:36:08 2025 +0800
  13. #
  14. # interactive rebase in progress; onto 130579e
  15. # Last commands done (3 commands done):
  16. #    squash 1fa1b57 fix: 6
  17. #    squash f54005d 合并fix7 8 9
  18. # No commands remaining.
  19. # You are currently rebasing branch 'master' on '130579e'.
  20. #
  21. # Changes to be committed:
  22. #       modified:   README.md
复制代码

生存退出,按下 esc 再按 :然后输入 wq 或 x 生存
如图:有 Successfully rebased and updated 字样就代表归并乐成了

  1. (base) ➜  gaolijie git:(master) git push -f
  2. Enumerating objects: 5, done.
  3. Counting objects: 100% (5/5), done.
  4. Delta compression using up to 12 threads
  5. Compressing objects: 100% (2/2), done.
  6. Writing objects: 100% (3/3), 342 bytes | 342.00 KiB/s, done.
  7. Total 3 (delta 1), reused 0 (delta 0), pack-reused 0
  8. remote: Powered by GITEE.COM [1.1.5]
  9. remote: Set trace flag 064712a5
  10. To https://gitee.com/Blue_Pepsi_Cola/gaolijie.git
  11. + f54005d...6950c9d master -> master (forced update)
复制代码
最后git push -f
2. 某个版本之前的commit记载归并

也可以指定归并某个版本之前的版本:git rebase -i 00c7d7ff 但不包罗 00c7d7ff,至归并他之前的。
00c7d7ff




免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

不到断气不罢休

金牌会员
这个人很懒什么都没写!

标签云

快速回复 返回顶部 返回列表