【问题标题】:git : How to uncomment the default commit message text? [duplicate]git:如何取消注释默认提交消息文本? [复制]
【发布时间】:2012-04-07 12:22:10
【问题描述】:

默认的 git 提交消息是:

# 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 <file>..." to unstage)
#
#   modified:   file1
#   modified:   file2
#

这对我来说很好。但默认情况下,我宁愿取消注释某些行:

# 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 <file>..." to unstage)

    modified:   file1
    modified:   file2
#

所以我不必每次都取消注释。 有可能吗?

谢谢

【问题讨论】:

  • 为什么要在提交信息中列出修改过的文件?这完全是多余的。
  • 这不是重复的问题。发帖人特别希望在提交消息中包含修改文件的列表,而另一个问题根本没有提及。

标签: git


【解决方案1】:

此信息很容易生成。不要在提交消息中包含此信息,因为它所能做的就是与提交中的实际更改不同步。相反,让 git 生成您稍后需要的信息。例如,git log --name-status 将显示修改了哪些文件。您甚至可以在.gitconfig 中设置alias 以使这些选项成为默认值。这种方法应该为您提供所需的所有信息,同时避免可能的陷阱和违反 git 约定。

【讨论】:

    猜你喜欢
    • 2016-04-23
    • 2014-11-27
    • 1970-01-01
    • 2019-02-14
    • 2013-11-02
    • 2011-06-18
    • 2016-04-26
    相关资源
    最近更新 更多