【问题标题】:Why does git call me "clever" when I reword the last commit message?当我改写最后一条提交消息时,为什么 git 称我为“聪明”?
【发布时间】:2014-06-06 13:54:31
【问题描述】:

我经常跑步

git commit --only --amend

改写我最近一次提交的提交信息。无论我的工作目录是否干净,这都会起作用。

今天我注意到,在执行此操作时,我的core.editor 中显示的编写提交消息的默认说明包括以下注释:

# Clever... amending the last one with dirty index.

除了有一点复活节彩蛋的魅力之外,这条消息应该告诉我什么?这是一种讽刺的方式,说我应该小心之前的提交(尤其是是否存在分阶段/未分阶段的更改)? 为什么即使我的工作目录是干净的,它也会显示出来?

【问题讨论】:

  • @gwho 哈哈...我知道git 可以做很多事情,但不要穿上我的裤子! ;)
  • 这是一个巨大的复活节彩蛋……而且就在复活节前后! git grep -l "Clever... amending the last one with dirty index"the Git repo 的克隆中:出现在builtin/commit.ccontrib/examples/git-commit.sh,以及看起来像其他语言的一些翻译文件中。
  • 我找到了引入行的提交(git log --oneline -S "Clever... amending the last one with dirty index." FTW!),once in April 20th, 2006 by Junio Hamano,另一个是Kristian Høgsberg on November 8th 2007
  • 没有直接关系,但显然 git 中还有其他复活节彩蛋。我尝试了this blog post 中的那个,但无法让它工作。如果你在 Git 存储库的克隆中执行 git grep "Yeeah",你肯定会看到该行仍然存在,即使在版本 1.9.0 中也是如此。

标签: git commit git-amend


【解决方案1】:

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

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>

我不是很精通 git,但在我看来,这确实是对 使用不带路径的--only 绕过脏索引

【讨论】:

  • +1 有趣。没有任何迹象表明作者认为在索引脏时重写提交消息是一个坏主意! :) 没有解释为什么人们希望消息显示在一个干净的工作目录中......
  • 为了避免我假设的额外逻辑。相关代码似乎主要集中在解析给定的参数上,所以我明白为什么你不想检查索引是否真的是脏的......
猜你喜欢
  • 1970-01-01
  • 2015-06-11
  • 1970-01-01
  • 2017-11-01
  • 2017-04-21
  • 2018-11-30
  • 2018-04-17
  • 1970-01-01
相关资源
最近更新 更多