【发布时间】:2021-05-15 15:24:05
【问题描述】:
我有一个包含 3 个提交的工作树:
➜ ~myproject git:(master) git log
commit a99cce8240495de29254b5df8745e41815db5a75
Author: My Name <my@mail.com>
Date: Thu Aug 16 00:59:05 2012 +0200
.gitignore edits
commit 5bccda674c7ca51e849741290530a0d48efd69e8
Author: My Name <my@mail.com>
Date: Mon Aug 13 01:36:39 2012 +0200
Create .gitignore file
commit 6707a66191c84ec6fbf148f8f1c3e8ac83453ae3
Author: My Name <my@mail.com>
Date: Mon Aug 13 01:13:05 2012 +0200
Initial commit (with a misleading message)
现在我想reword我的第一次提交的提交信息(6707a66)
➜ ~myproject git:(master) git rebase -i 6707
(……进入 vim)
pick 5bccda6 Create .gitignore file
pick a99cce8 .gitignore edits
# Rebase 6707a66..a99cce8 onto 6707a66
#
# 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
在这种情况下,我希望更正(reword 在 git 用语中)有问题的提交消息:
初始提交(带有误导性消息)
…适当的东西。
不出所料,我上面的尝试没有成功,因为第一次提交显然没有任何 parent 提交。 (当您rebase 时,您需要将下一个最旧的提交之前引用到您希望reword 的提交,对吧?)
因此,我的问题的要点是,您可以通过其他任何方式来实现吗?
【问题讨论】:
-
或者你可以一直把它作为一个存储库tawdry quirk.
-
^ 非常正确...我以为我已经正确搜索了这个特定问题,但这与我的相同。有大量完善我的问题的文案。 :-P
-
@hced: :) 你的文案不会浪费——它会帮助其他人在未来找到解决方案,即使它作为副本被关闭
-
遇到此问题的任何人都可能会发现 my answer 到 Changing the message of the first commit? (git) 会有所帮助。
标签: git message git-rebase git-commit revision-history