有没有办法在发布前找到 GIT 中的重要提交?
Is there a way to find the important commits in GIT before a release?
因为不仅是主要的变化,可能是安装的依赖项,而且都是在发布之前没有一一检查的?
因为 Git 不知道哪些提交对你来说 重要,你必须首先定义你自己的一组 guidelines/format 如何您编写提交消息,稍后您可以使用这些消息轻松区分为特定开发阶段所做的所有提交。
例如:
- 如果是错误修复,请在提交消息前加上“[错误修复]”
- 如果是新功能,请在提交消息前加上“[功能]”
- 如果是项目设置更改,请在提交消息前加上“[迁移]”
然后,一旦所有分支都合并到主分支(假设是 develop),检查 develop 分支并使用 git log --grep=<PATTERN>
来识别一组特定的提交。
例如,如果您只需要错误修复提交,请执行以下操作:
git log --grep="bugfix"
这将向您显示提交消息中带有“bugfix”的所有提交。
如果您只需要特定时期的提交,您可以使用 --since=<date>
选项:
git log --since="2017-06-01" --grep="bugfix"
如果你想要一个格式化的列表(我想你可以很容易地输出到某种发行说明),你可以使用 --format=<format>
选项:
git log --since="2017-06-01" --grep="bugfix" --format="(%ci) %h : %s"
上面的命令会给你这样的东西:
(2017-06-18 18:26:36 +0800) 63f330f : [bugfix] prevent crash when dialog is sent to background
(2017-07-01 10:03:40 +0800) cdcbd91 : [bugfix] remove extra row at the end of the list
您可以查看 other format options from the complete git log docs
。
基本上,这完全取决于您的提交消息格式。
作为提示,您可以考虑使用 commit.template
来更轻松地格式化您的提交消息。
commit.template
If you set this to the path of a file on your system,
Git will use that file as the default message when you commit. For
instance, suppose you create a template file at ~/.gitmessage.txt
that
looks like this:
subject line
what happened
[ticket: X]
因为不仅是主要的变化,可能是安装的依赖项,而且都是在发布之前没有一一检查的?
因为 Git 不知道哪些提交对你来说 重要,你必须首先定义你自己的一组 guidelines/format 如何您编写提交消息,稍后您可以使用这些消息轻松区分为特定开发阶段所做的所有提交。
例如:
- 如果是错误修复,请在提交消息前加上“[错误修复]”
- 如果是新功能,请在提交消息前加上“[功能]”
- 如果是项目设置更改,请在提交消息前加上“[迁移]”
然后,一旦所有分支都合并到主分支(假设是 develop),检查 develop 分支并使用 git log --grep=<PATTERN>
来识别一组特定的提交。
例如,如果您只需要错误修复提交,请执行以下操作:
git log --grep="bugfix"
这将向您显示提交消息中带有“bugfix”的所有提交。
如果您只需要特定时期的提交,您可以使用 --since=<date>
选项:
git log --since="2017-06-01" --grep="bugfix"
如果你想要一个格式化的列表(我想你可以很容易地输出到某种发行说明),你可以使用 --format=<format>
选项:
git log --since="2017-06-01" --grep="bugfix" --format="(%ci) %h : %s"
上面的命令会给你这样的东西:
(2017-06-18 18:26:36 +0800) 63f330f : [bugfix] prevent crash when dialog is sent to background (2017-07-01 10:03:40 +0800) cdcbd91 : [bugfix] remove extra row at the end of the list
您可以查看 other format options from the complete git log docs
。
基本上,这完全取决于您的提交消息格式。
作为提示,您可以考虑使用 commit.template
来更轻松地格式化您的提交消息。
commit.template
If you set this to the path of a file on your system, Git will use that file as the default message when you commit. For instance, suppose you create a template file at
~/.gitmessage.txt
that looks like this:
subject line
what happened
[ticket: X]