如何填写一个空的提交信息? [英] How to fill in an empty commit message?
问题描述
直到一分钟前,我有一个Git存储库,其中最后一次提交的消息为空.我已经用git rebase -i
压缩了一个新的提交来填充了它(无论如何我还是打算修改内容),但是我仍然想知道是否有适当的方法来填充空的提交消息.
Until a minute ago, I had a Git repo where the last commit had an empty commit message. I've filled it in by squashing a new commit onto it with git rebase -i
(I was planning to amend the contents anyway) but I would still like to know if there's a proper way to fill in empty commit messages.
我尝试过
git commit --amend
但是那没有用,然后我尝试了
but that didn't work, then I tried
git rebase -i HEAD^
和reword
.两次尝试都导致Git说
and a reword
. Both attempts resulted in Git saying
fatal: commit has empty message
然后退出.
编辑:为了澄清,最终起作用的是
EDIT: to clarify, what finally worked was
# change some stuff
git commit
git rebase -i HEAD~2
# squash the last two commits
但这似乎是一种黑客行为.
but this seems like a hack.
推荐答案
This seems to be a bug which hasn't been fixed yet (although there are proposed patches for it). As a workaround, you can provide the message on the command line:
git commit --amend -m "foo"
这篇关于如何填写一个空的提交信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!