当我重写最后一次提交消息时,为什么git称我为"聪明"?

its*_*eyd 18 git commit git-amend

我经常跑

git commit --only --amend
Run Code Online (Sandbox Code Playgroud)

重写我所做的最新提交的提交消息.无论我的工作目录是否干净,这都可以.

今天我注意到,在执行此操作时,我写的提交消息的默认指令core.editor包括以下注释:

# Clever... amending the last one with dirty index.
Run Code Online (Sandbox Code Playgroud)

除了有一点复活节彩蛋的魅力,这个消息应该告诉我什么?这是否具有讽刺意味的说法,在弄乱以前的提交时我应该小心(特别是如果存在分阶段/未分阶段的更改)?即使我的工作目录是干净的,它为什么会出现?

mon*_*ell 8

我认为这可能是原始提交消息:

git-commit --amend: two fixes.

When running "git commit --amend" only to fix the commit log
message without any content change, we mistakenly showed the
git-status output that says "nothing to commit" without
commenting it out.

If you have already run update-index but you want to amend the
top commit, "git commit --amend --only" without any paths should
have worked, because --only means "starting from the base
commit, update-index these paths only to prepare the index to
commit, and perform the commit".  However, we refused -o without
paths.

Signed-off-by: Junio C Hamano <junkio@cox.net>
Run Code Online (Sandbox Code Playgroud)

我不是很精通,但对我来说,看起来像是通过使用--only没有路径来绕过脏索引的真正恭维

  • 为了避免额外的逻辑,我假设.相关代码似乎主要集中在解析给定的参数,所以我可以看到为什么你不想检查索引是否实际上是脏的... (2认同)