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
经验证,这篇文章有点小问题,让我有时间再更正一下
git commit 合并的更多相关文章
- git commit 合并到指定分支
1. 将指定的commit合并到当前分支 git cherry-pick commit_id 2. 合并多个连续 commit 到指定分支 假设需要合并 devlop 上从 fb407a3f 到 9 ...
- git cherry-pick合并某个commit
1.使用方法及其作用 git cherry-pick可以选择某一个分支中的一个或几个commit(s)来进行操作(操作的对象是commit).例如,假设我们有个稳定版本的分支,叫v2.0,另外还有个开 ...
- git commit -am 合并操作
二,合并的操作 1, 首先按需修改文件 echo >> lz66303.txt 2, 然后按需提交被修改的文件到HEAD缓存区,并把这个修改记录到分支中 git commit -am&qu ...
- Git自动化合并多个Commit
目录 git rebase逻辑 git editor的修改 处理git-rebase-todo文件 Python实现 当我们有多个commit或者从开源处拿到多个commit时,想合成一个commit ...
- git将多个commit合并成一个
1. 查看提交历史(最近10个) git log - 2. 回到前面第十个commit,且将后面九个commit提交的内容状态改为未提交 git reset commitID(第十个commit的ID ...
- git只合并某一个分支的某个commit
第一种情况:只合并一个commit git checkout develop-hbb git cherry-pick 7c32be61 以上,7c32be61是develop上的一个fix bug的c ...
- git将多个commit合并成一个新的commit
问题: 有以下commit: 323udd ede234 6e7s6e 要合并第一个和第二个commit 方法有二: 方法一 使用git rebase -i hash-id,-i表示以交互模式进行co ...
- [转] git merge 将多个commit合并为一条之--squash 选项
[FROM] https://blog.csdn.net/themagickeyjianan/article/details/80333645 1.一般的做法(直接git merge) Git相对于C ...
- 巧用 git rebase 合并多个 commit。
一.为什么需要合并多个 commit 呢? 有时候,我们开发一个功能. 修修补补 commit 了很多次,过多的 commit 会显得很复杂. 不够直观,不能比较清晰查看那些 commit 是对应 ...
随机推荐
- SteveY对Amazon和Google平台的吐槽
Steve Yegge, Amazon的前员工,现任Google员工,其本来想在Google+上和Google的员工讨论一些关于平台的东西,结果不小心把圈子设成了Public,结果这篇文章就公开给了全 ...
- 实现超级简单的bug管理系统
大家可以试着去实现一个超级简单的bug管理系统 不需要鉴权,也就是不需要登陆 有tag管理功能,缺陷上可以加tag,通过tag区分bug的状态和类型 bug的增删改查功能 bug描述支持markdow ...
- js中为什么你不敢用 “==”
文章引用:http://0313.name/archives/480 前言 类型转换在各个语言中都存在,而在 JavaScript 中由于缺乏对其的了解而不慎在使用中经常造成bug被人诟病.为了避免某 ...
- SQLServer2012 (非)聚集索引存储探究
SQLServer2012 (非)聚集索引存储探究 Author:zfive5(zidong) Email:zfive5@163.com 引子 因为写了前一篇文字<SQLServer2012 表 ...
- Intellij dea 注释行如何自动缩进?
Intellij dea 注释行如何自动缩进? 进入 Settings -> Code Style -> Java ,在右边选择 “Code Generation” Tab,然后找到 ...
- JAVA classpath jar问题[zz]
classpath问题可以说是所有初学者头疼的问题,偶也一样. 1) classpath的作用: 它的作用就事让java找到你所要执行,或你拥有的类. 2) classpath的设置: 设置cla ...
- Hadoop hostname: Unknown host
本来下想在一台虚拟机上,搭建一个hadoop的测试hadoop,用于调试和阅读hadoop源代码,发现在虚拟机上执行: $hostname -i hostname: Unknown host 这个是因 ...
- grafana 的面板设置
1.工作中我们会计算连个字段的四则运算
- OOM killer(Out Of Memory killer)
最近接连遇到两个情况就是接连进程把kill掉 第一个情况就是有一个java进程被kill了.原因是我这个服务器上海部署了一个node服务,这个node服务大家都不熟悉.所以在使用的时候没有注意内存的使 ...
- docker容器网络通信原理分析
概述 自从docker容器出现以来,容器的网络通信就一直是大家关注的焦点,也是生产环境的迫切需求.而容器的网络通信又可以分为两大方面:单主机容器上的相互通信和跨主机的容器相互通信.而本文将分别针对这两 ...