美文网首页
Git 合并多次 commit

Git 合并多次 commit

作者: 浅忆_0810 | 来源:发表于2021-03-15 19:21 被阅读0次

合并多次提交记录

git rebase的危险性

  1. 先使用git log查看提交历史

    log
  2. 使用git rebase进行git压缩

    # 对最近的 3个 commit 进行 rebase 
    git rebase -i HEAD~3 
    
    info

    对于 commit 合并可以使用squashfixup 指令,

    squash 会将该 commit的注释添加到上一个 commit 注释中

    fixup 是放弃当前commit 的注释

    detail
  3. 编辑后保存退出,git 会自动压缩提交历史

    如果有冲突,解决冲突后,使用 git rebase --continue重新回到当前的 git压缩过程

  4. git push -f 推送到远程仓库

相关文章

网友评论

      本文标题:Git 合并多次 commit

      本文链接:https://www.haomeiwen.com/subject/jqvbfltx.html