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

git commit 合并的更多相关文章

  1. git commit 合并到指定分支

    1. 将指定的commit合并到当前分支 git cherry-pick  commit_id 2. 合并多个连续 commit 到指定分支 假设需要合并 devlop 上从 fb407a3f 到 9 ...

  2. git cherry-pick合并某个commit

    1.使用方法及其作用 git cherry-pick可以选择某一个分支中的一个或几个commit(s)来进行操作(操作的对象是commit).例如,假设我们有个稳定版本的分支,叫v2.0,另外还有个开 ...

  3. git commit -am 合并操作

    二,合并的操作 1, 首先按需修改文件 echo >> lz66303.txt 2, 然后按需提交被修改的文件到HEAD缓存区,并把这个修改记录到分支中 git commit -am&qu ...

  4. Git自动化合并多个Commit

    目录 git rebase逻辑 git editor的修改 处理git-rebase-todo文件 Python实现 当我们有多个commit或者从开源处拿到多个commit时,想合成一个commit ...

  5. git将多个commit合并成一个

    1. 查看提交历史(最近10个) git log - 2. 回到前面第十个commit,且将后面九个commit提交的内容状态改为未提交 git reset commitID(第十个commit的ID ...

  6. git只合并某一个分支的某个commit

    第一种情况:只合并一个commit git checkout develop-hbb git cherry-pick 7c32be61 以上,7c32be61是develop上的一个fix bug的c ...

  7. git将多个commit合并成一个新的commit

    问题: 有以下commit: 323udd ede234 6e7s6e 要合并第一个和第二个commit 方法有二: 方法一 使用git rebase -i hash-id,-i表示以交互模式进行co ...

  8. [转] git merge 将多个commit合并为一条之--squash 选项

    [FROM] https://blog.csdn.net/themagickeyjianan/article/details/80333645 1.一般的做法(直接git merge) Git相对于C ...

  9. 巧用 git rebase 合并多个 commit。

    一.为什么需要合并多个 commit 呢?   有时候,我们开发一个功能. 修修补补 commit 了很多次,过多的 commit 会显得很复杂. 不够直观,不能比较清晰查看那些 commit 是对应 ...

随机推荐

  1. python标准库介绍——37 signal 模块详解

    ==signal 模块== 你可以使用 ``signal`` 模块配置你自己的信号处理器 (signal handler), 如 [Example 3-11 #eg-3-11] 所示. 当解释器收到某 ...

  2. 关于 Xcode 调试工具 GDB and LLDB

    xcode 5 好像弃用了GDB .而默认使用苹果自己开发的调试工具 LLDB. http://iosre.com/forum.php?mod=viewthread&tid=52    LLD ...

  3. 【Android教程】Android用户系统管理

    原文:http://android.eoe.cn/topic/android_sdk Android用户迷恋于在自己的设备上安装他们所喜欢的应用.让您的应用受用户喜欢的一种方法就是让它个性化.Andr ...

  4. Bug:java.lang.StackOverflowError: stack size 8MB

    在开发的时候遇到了这个Bug:java.lang.StackOverflowError: stack size 8MB Log: 11-27 14:16:37.093 21892-21892/com. ...

  5. linux经常使用命令-帮助命令-授之以渔

    原创Blog,转载请注明出处 http://blog.csdn.net/hello_hwc 我的虚拟机系统是CentOS.版本号较老,谅解 一.为什么要学习帮助命令?   授人以鱼不如授人以渔.学会了 ...

  6. Atitit opencv 模板匹配

    Atitit opencv 模板匹配 1.1. 图片1 1.2. Atitit opencv 模板匹配  6中匹配算法貌似效果区别不大1 1.3. 对模板缩放的影响 一般的缩放可以,太大了就歇菜了.. ...

  7. JavaWEB springmvc 使用定时任务

    1.配置web.xml 在web.xml配置使用springmvc框架,其他配置略. <display-name>xxx.com</display-name> <!-- ...

  8. Fluent UDF【4】:C语言

    Fluent UDF利用的是C语言,本文简单介绍在UDF中经常会用到的C语言常识. 本文部分内容来自UDF手册. 1 C语言中的注释 C语言中的注释利用/*及*/来实现.例如: /*这是一个注释*/ ...

  9. MYSQL performance

    https://www.mysql.com/why-mysql/performance/ https://www.slideshare.net/oysteing/how-to-analyze-and- ...

  10. 每日英语:Foreign Tourists Skip Beijing

    Overseas tourists continued to shun Beijing through 2013. shun:避开,避免,回避 Amid rising pollution and a ...