我不知道 git-notes(1) 的原作者的意图是什么。但我个人会说不。
git-notes(1) 用于向提交添加可变元数据。可以肯定的是,如果类别是可变的(例如,您可能想在提交后一段时间添加类别并且您不想更改该提交),那么 git-notes(1) 可能会很有用。但是为什么要使用多个命名空间呢?为什么不将它们存储在一个命名空间下?类别(我想)只是一个关键字,您可以轻松地将简单的字符串附加到注释中。所以你最终可能会得到这样的注释:
bug fix
breaking change
refactor
做完之后:
git notes --ref=yourref --append -m 'bug fix'
git notes --ref=yourref --append -m 'breaking change'
git notes --ref=yourref --append -m 'refactor'
但是,如果您只需要不可变的元数据(即,您在编写提交时就知道自己想要什么类别),那么只需将类别添加到您的提交消息中就更简单了:
Big change #4564
Keywords: breaking change, refactor, bugfix
我在这里使用了“关键字”这个名称。
这可能是一个日志:
$ git log --patch
commit 498cc43746aa89a0bb335781eb8157908da12532 (HEAD -> master)
Author: Victor Version Control <vvc@vcs.org>
Date: Fri Sep 24 21:01:47 2021 +0200
Set the scene
Keywords: worldbuilding
diff --git a/novel.md b/novel.md
index 8bf53766294f..999578522b1f 100644
--- a/novel.md
+++ b/novel.md
@@ -1 +1,4 @@
Once upon a time there was an ogre.
+
+He lived in an ogre village in South-Okranazoa, the highlands west of
+the lowlands and plains of Kzherbadai.
commit b307a1c02eec479888cba7676e00903071fb0878
Author: Victor Version Control <vvc@vcs.org>
Date: Fri Sep 24 20:59:46 2021 +0200
Start the story
Keywords: intro, ogrekin
diff --git a/novel.md b/novel.md
new file mode 100644
index 000000000000..8bf53766294f
--- /dev/null
+++ b/novel.md
@@ -0,0 +1 @@
+Once upon a time there was an ogre.
如果您想过滤某些关键字的日志,那么您可以使用这个粗略且有些错误的 MVP:
$ git log --grep='Keywords:.*ogrekin'
commit b307a1c02eec479888cba7676e00903071fb0878
Author: Victor Version Control <vvc@vcs.org>
Date: Fri Sep 24 20:59:46 2021 +0200
Start the story
Keywords: intro, ogrekin