2019-06-17 怎么修改老旧的commit message

2019-06-17  本文已影响0人  张大志的博客
[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   #发现描述信息已经修改

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

保存退出后跳转到此
# 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  #发现已经合并
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
上一篇 下一篇

猜你喜欢

热点阅读