2019-06-17 怎么修改老舊的commit message和把多個commit合并成一個

[root@VM_0_3_centos project]# git log
commit 895335f40dfbebae3ad933a10f4ab7828885bf41
Author: eagle <307509855@qq.com>
Date:   Fri Jun 14 15:35:09 2019 +0800

    add test file

commit 936700dcbe822af203e0b22644353c948b60e52f  #修改message
Author: eagle <307509855@qq.com>
Date:   Fri Jun 14 14:31:36 2019 +0800

    mv readme.txt readme.md

commit 72bf4683bc7f8405f0ab3c976b62abffe4b487b4
Author: eagle <307509855@qq.com>
Date:   Fri Jun 14 14:29:20 2019 +0800

    add readme.txt
[root@VM_0_3_centos project]# git rebase -i 72bf4683bc  #使用此命令,-i指向父提交
r 936700d mv readme.txt readme.md #將pick改為r烟号,并保存退出
pick 895335f add test file

# Rebase 72bf468..895335f onto 72bf468
#
# Commands:
#  p, pick = use 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
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.
#
# Note that empty commits are commented out

Rebasing (1/2)  #保存退出后會跳到此文件
move readme.txt readme.md  #修改message后导披,保存退出即可

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# HEAD detached from 72bf468
# You are currently editing a commit while rebasing branch 'master' on '72bf468'.
#
# Changes to be committed:
#   (use "git reset HEAD^1 <file>..." to unstage)
#
#       renamed:    readme.txt -> readme.md
#
[root@VM_0_3_centos project]# git log
commit 93446f01c1d26f60f767d2851bc6f5568ac80179
Author: eagle <307509855@qq.com>
Date:   Fri Jun 14 15:35:09 2019 +0800

    add test file

commit 7be55de3dc794d424ef62332d983839bc119f882
Author: eagle <307509855@qq.com>
Date:   Fri Jun 14 14:31:36 2019 +0800

    move readme.txt readme.md   #發(fā)現(xiàn)描述信息已經(jīng)修改

commit 72bf4683bc7f8405f0ab3c976b62abffe4b487b4
Author: eagle <307509855@qq.com>
Date:   Fri Jun 14 14:29:20 2019 +0800

    add readme.txt

多個commit合并成一個

[root@VM_0_3_centos project]# git log
commit acc1724d6e26b1771abeabab2356379f7934a4f1
Author: eagle <307509855@qq.com>
Date:   Mon Jun 17 15:03:46 2019 +0800

    add  index.html

commit f91e94a2a1a800047ea2615184ca078113f50bc5
Author: eagle <307509855@qq.com>
Date:   Mon Jun 17 15:02:58 2019 +0800

    add style.css

commit 93446f01c1d26f60f767d2851bc6f5568ac80179
Author: eagle <307509855@qq.com>
Date:   Fri Jun 14 15:35:09 2019 +0800

    add test file

commit 7be55de3dc794d424ef62332d983839bc119f882
Author: eagle <307509855@qq.com>
Date:   Fri Jun 14 14:31:36 2019 +0800

    move readme.txt readme.md

commit 72bf4683bc7f8405f0ab3c976b62abffe4b487b4
Author: eagle <307509855@qq.com>
Date:   Fri Jun 14 14:29:20 2019 +0800

[root@VM_0_3_centos project]# git rebase -i 7be55de3   #要合并中間兩次提交
pick 93446f0 add test file
s f91e94a add style.css  #把add style.css合并到前一次提交
pick acc1724 add  index.html  #最近一次提交不動

# Rebase 7be55de..acc1724 onto 7be55de
#
# Commands:
#  p, pick = use 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
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.
#
# Note that empty commits are commented out

保存退出后跳轉(zhuǎn)到此
# This is a combination of 2 commits.
hebingzhongjianliangge    #增加合并后的message
# The first commit's message is:

add test file

# This is the 2nd commit message:

add style.css

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# HEAD detached at 93446f0
# You are currently editing a commit while rebasing branch 'master' on '7be55de'.
#
# Changes to be committed:
#   (use "git reset HEAD^1 <file>..." to unstage)
#
#       new file:   style.css
#       new file:   test/f1
#
[root@VM_0_3_centos project]# git log  #發(fā)現(xiàn)已經(jīng)合并
commit 58a63bf128c502c65e488b0fd25f7bdd27f84545
Author: eagle <307509855@qq.com>
Date:   Mon Jun 17 15:03:46 2019 +0800

    add  index.html

commit 37c34f5ac9afa9481a2281e6c51d013f237e51d0
Author: eagle <307509855@qq.com>
Date:   Fri Jun 14 15:35:09 2019 +0800

    hebingzhongjianliangge
    
    add test file
    
    add style.css

commit 7be55de3dc794d424ef62332d983839bc119f882
Author: eagle <307509855@qq.com>
Date:   Fri Jun 14 14:31:36 2019 +0800

    move readme.txt readme.md

commit 72bf4683bc7f8405f0ab3c976b62abffe4b487b4
Author: eagle <307509855@qq.com>
Date:   Fri Jun 14 14:29:20 2019 +0800

    add readme.txt
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末署辉,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子鳖悠,更是在濱河造成了極大的恐慌拼岳,老刑警劉巖,帶你破解...
    沈念sama閱讀 217,406評論 6 503
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件顽聂,死亡現(xiàn)場離奇詭異,居然都是意外死亡盯仪,警方通過查閱死者的電腦和手機紊搪,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,732評論 3 393
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來全景,“玉大人耀石,你說我怎么就攤上這事“只疲” “怎么了滞伟?”我有些...
    開封第一講書人閱讀 163,711評論 0 353
  • 文/不壞的土叔 我叫張陵,是天一觀的道長炕贵。 經(jīng)常有香客問我梆奈,道長,這世上最難降的妖魔是什么鲁驶? 我笑而不...
    開封第一講書人閱讀 58,380評論 1 293
  • 正文 為了忘掉前任鉴裹,我火速辦了婚禮,結(jié)果婚禮上钥弯,老公的妹妹穿的比我還像新娘径荔。我一直安慰自己,他們只是感情好脆霎,可當(dāng)我...
    茶點故事閱讀 67,432評論 6 392
  • 文/花漫 我一把揭開白布总处。 她就那樣靜靜地躺著,像睡著了一般睛蛛。 火紅的嫁衣襯著肌膚如雪鹦马。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,301評論 1 301
  • 那天忆肾,我揣著相機與錄音荸频,去河邊找鬼。 笑死客冈,一個胖子當(dāng)著我的面吹牛旭从,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播,決...
    沈念sama閱讀 40,145評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼和悦,長吁一口氣:“原來是場噩夢啊……” “哼退疫!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起鸽素,我...
    開封第一講書人閱讀 39,008評論 0 276
  • 序言:老撾萬榮一對情侶失蹤褒繁,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后馍忽,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體棒坏,經(jīng)...
    沈念sama閱讀 45,443評論 1 314
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,649評論 3 334
  • 正文 我和宋清朗相戀三年舵匾,在試婚紗的時候發(fā)現(xiàn)自己被綠了俊抵。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片谁不。...
    茶點故事閱讀 39,795評論 1 347
  • 序言:一個原本活蹦亂跳的男人離奇死亡坐梯,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出刹帕,到底是詐尸還是另有隱情吵血,我是刑警寧澤,帶...
    沈念sama閱讀 35,501評論 5 345
  • 正文 年R本政府宣布偷溺,位于F島的核電站蹋辅,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏挫掏。R本人自食惡果不足惜侦另,卻給世界環(huán)境...
    茶點故事閱讀 41,119評論 3 328
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望尉共。 院中可真熱鬧褒傅,春花似錦、人聲如沸袄友。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,731評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽剧蚣。三九已至支竹,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間鸠按,已是汗流浹背礼搁。 一陣腳步聲響...
    開封第一講書人閱讀 32,865評論 1 269
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留目尖,地道東北人馒吴。 一個月前我還...
    沈念sama閱讀 47,899評論 2 370
  • 正文 我出身青樓,卻偏偏與公主長得像,于是被迫代替她去往敵國和親募书。 傳聞我的和親對象是個殘疾皇子绪囱,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 44,724評論 2 354

推薦閱讀更多精彩內(nèi)容

  • 1.說明 有時commit多了看著會不爽.所以想合并掉一些commit. 這里是最簡單的情況, 一條線下來N個co...
    NowBurn閱讀 3,098評論 0 0
  • 0. 引言當(dāng)你提交代碼進行代碼審查時或者創(chuàng)建一次pull request (這在開源項目中經(jīng)常發(fā)生),你的代碼在被...
    pansly閱讀 47,564評論 5 9
  • git多個commit合并 有時候我們本地寫代碼莹捡,因為要拉取同組其他小伙伴的代碼鬼吵,所以需要先把代碼commit,或...
    Heath閱讀 420評論 0 1
  • 李文軒 2019-02-24 修改最近一次 commit 的 message: 變基(rebase)命令的特性 變...
    WenxuanLi閱讀 290評論 0 0
  • 需求 開發(fā)過程篮赢,自己的一個模塊沒有完成或者有事情走開了齿椅,不想提交到倉庫,但是有恐怕代碼覆蓋或者丟失启泣,就把代碼提交到...
    gzfgeh閱讀 4,781評論 0 1