在git commit消息中使用“#”有什么好处?

时间:2010-10-01 12:18:12

标签: git

在提交消息中,有一条规则说:
“以'#'开头的行将被忽略”

现在我很困惑,如果这些线被忽略,为什么我们一直使用它们呢? 运行“git log”只显示##未启动的行,并且不显示忽略的行。

是否有任何命令显示以'#'开头的行?

2 个答案:

答案 0 :(得分:7)

好吧,当您编写git commit时,通常需要编辑提交消息 作为提醒,有很多#行,它们将显示将提交的内容(重命名,新增,修改)以及将被忽略的内容。我认为这个功能非常有用 - 但我不想在稍后的提交消息中看到它。

示例:

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# On branch master
# Changes to be committed:
#   (use "git reset HEAD ..." to unstage)
#
#   modified:   file_a.doc
#   deleted:    file_b.jpg
#
# Untracked files:
#   (use "git add ..." to include in what will be committed)
#
#   directory/

我认为这就是#行的全部原因。

答案 1 :(得分:1)

被'忽略'意味着没有保存。注释行仅适用于您实际编写提交消息的时间 - 它们不会保存以供以后使用。