在git中,将多个注释格式化为单个提交有哪些好的约定

chu*_*boy 5 git dvcs

我想知道人们通常如何在一次提交中分离多个评论.明星?逗号?单独的线?只是想知道你发现什么是最好的.

我现在正在使用这个,当我通过Emacs添加评论,但不确定我喜欢它:

Added error messaging
Cleaned up sign-up UI
Added recaptcha

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# Committer: Conrad Chu <chuboy@conradlaptop.local>
#
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       modified:   app/controllers/api_controller.rb
#       modified:   app/controllers/users_controller.rb
#       modified:   app/models/user.rb
#       modified:   app/views/users/new.html.erb
#       modified:   app/views/users/show.html.erb
#       modified:   config/environment.rb
#       modified:   db/migrate/20090923001219_create_users.rb
#       modified:   db/schema.rb
#       modified:   doc/README
#       modified:   public/stylesheets/master.css
#       new file:   vendor/plugins/recaptcha/.gitignore
#       new file:   vendor/plugins/recaptcha/CHANGELOG
Run Code Online (Sandbox Code Playgroud)

u0b*_*6ae 18

Git对日志消息有很强的约定,但规则很简单:

  1. 第一行是提交的摘要
  2. 第一行可能有一个范围描述前缀"module:"
  3. 第二行是空的
  4. 然后在段落中进行讨论,只要它是必要的

作为开始,您应该使用这些约定,因为演示工具甚至依赖于它们(第二行是空的很重要,在许多情况下,您只会看到第一行摘要.)

使用git,提交应该很小,所以第一个答案当然是,你不应该在一次提交中修改很多东西.你应该有三个提交,而不是一个.

但是,你可以在提交日志中写一篇完整的文章,在那里你可以描述他们所有细节的变化(动机,丢弃的设计,想法).如果这三个变化真正属于一起,那么本文将明确原因.

我发现了更多描述相同Git Commit消息约定的指令,其中git命令依赖于特定格式.(大多数都基于现有的约定:通过电子邮件发送的补丁.)