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
    
    • 经验证,这篇文章有点小问题,让我有时间再更正一下

  • 相关阅读:
    hdu 5696 区间的价值 单调栈+rmq
    bzoj 3039: 玉蟾宫 单调栈或者悬线法求最大子矩阵和
    bzoj 2435: [Noi2011]道路修建 dfs
    Codeforces gym 100971 D. Laying Cables 单调栈
    codeforces GYM 100971F 公式题或者三分
    UVA 10539
    BZOJ 1079: [SCOI2008]着色方案 DP
    UVA 11426
    UVA 11728
    UVA 10090
  • 原文地址:https://www.cnblogs.com/chenfulin5/p/7831215.html
Copyright © 2011-2022 走看看