zoukankan      html  css  js  c++  java
  • git commit 合并

    • 日常 git 管理代码的时候,经常因为因为一些小的代码改动而进行一次 git commit , 但是这样造成的后果就是小的 git commit 很多很杂。

    • 今天特意的研究了一些 git commit 的合并方法。

    • 首先,使用 git log 看 log 信息。

        root@aplex:/home/cmi_at101/test/filesystem_test/cmi_at101_filesystem# git log
        commit 93ba40a42595edcbdb5adbab33d8c2dc5409f330
        Author: root <root@aplex.(none)>
        Date:   Mon Nov 13 16:45:55 2017 +0800
    
            ADD empty directory
    
        commit 0e35ffa5bdb248464ff2c6587b33206e021d86fc
        Author: root <root@aplex.(none)>
        Date:   Mon Nov 13 16:37:43 2017 +0800
    
            CMI-AT1010 filesystem init
    
    • 这里我们看到有两个 git commit , HASH Z值分别为 93ba40a4259 和 0e35ffa5bdb

    • 这里,我们 使用 git rebase -i HEAD~1 进行合并

        squash 93ba40a ADD empty directory          # 将要合并的 commit 
    
        # Rebase 0e35ffa..93ba40a onto 0e35ffa
        #
        # Commands:
        #  p, pick = use commit   使用这个commit 
        #  r, reword = use commit, but edit the commit message
        #  e, edit = use commit, but stop for amending
        #  s, squash = use commit, but meld into previous commit
        #  f, fixup = like "squash", but discard this commit's log message
        #  x, exec = run command (the rest of the line) using shell
        #
        # If you remove a line here THAT COMMIT WILL BE LOST.
        # However, if you remove everything, the rebase will be aborted.
        #
     
        Init CMI-AT101 filesystem     # commit  message
    
        保存退出
        新的commit  生成
    
    • 如果操作有误,可以使用 git rebase --abort 进行恢复

        root@aplex:/home/cmi_at101/test/filesystem_test/cmi_at101_filesystem# git log
        commit 0e35ffa5bdb248464ff2c6587b33206e021d86fc
        Author: root <root@aplex.(none)>
        Date:   Mon Nov 13 16:37:43 2017 +0800
    
            CMI-AT1010 filesystem init
        root@aplex:/home/cmi_at101/test/filesystem_test/cmi_at101_filesystem# git rebase --abort
        root@aplex:/home/cmi_at101/test/filesystem_test/cmi_at101_filesystem# git log
        commit 93ba40a42595edcbdb5adbab33d8c2dc5409f330
        Author: root <root@aplex.(none)>
        Date:   Mon Nov 13 16:45:55 2017 +0800
    
            ADD empty directory
    
        commit 0e35ffa5bdb248464ff2c6587b33206e021d86fc
        Author: root <root@aplex.(none)>
        Date:   Mon Nov 13 16:37:43 2017 +0800
    
            CMI-AT1010 filesystem init
    
    • 经验证,这篇文章有点小问题,让我有时间再更正一下

  • 相关阅读:
    第十一单元 beego验证
    第九单元 ORM
    第六单元 go操作redis
    第五单元 go操作mysql
    第四单元 参数配置
    springboot使用外置tomcat
    ⚡ 第二.三章顺序表与链表⚡
    c语言程序设计题 译密码
    翁恺 java进阶第一周作业
    Java 构造素数表的两种方法
  • 原文地址:https://www.cnblogs.com/chenfulin5/p/7831215.html
Copyright © 2011-2022 走看看