例如:
git commit -am "Something"
git notes append -m "Dark "
git commit -am "Something"
git notes append -m "Side"
git rebase -i
# now I squash two commits and I expect to see "Dark Side" here
# but it show that note is undefined
git notes show
Run Code Online (Sandbox Code Playgroud)
me_*_*and 14
问题几乎可以肯定是你的配置; 假设您有其他默认配置,您需要设置notes.rewriteRef选项以refs/notes/commits使其生效.
因此,您需要的神奇命令是:
git config notes.rewriteRef refs/notes/commits
Run Code Online (Sandbox Code Playgroud)
在上述之后,压缩提交应该加入两个注释.
然而,他们之间会有新的界限; 我怀疑是否禁用了这种行为,所以你得到的东西就像在你的例子中那样需要在Git源代码中进行黑客攻击.
从git help config(强调我的):
notes.rewriteRef在重写期间复制注释时,指定应复制其注释的(完全限定的)引用.ref可以是glob,在这种情况下,将复制所有匹配引用中的注释.您也可以多次指定此配置.
没有默认值; 您必须配置此变量以启用注释重写.将其设置
refs/notes/commits为启用默认提交注释的重写.可以使用
GIT_NOTES_REWRITE_REF环境变量覆盖此设置,该环境变量必须是以冒号分隔的引用或整数列表.
(参见用于描述notes.rewriteMode和notes.rewrite.<command>,这两者默认为我们所需要的,即价值concatenate和true分别.)
以上测试类似于以下内容:
$ git init
Initialized empty Git repository
$ git config notes.rewriteRef refs/notes/commits
$ git add a # Here's a file I created earlier
$ git commit -am 'Initial commit'
[master (root-commit) 93219cb] Initial commit
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 a
$ echo a >>a
$ git commit -am 'Something'
[master 3c17aca] Something
1 files changed, 1 insertions(+), 0 deletions(-)
$ git notes append -m 'Dark '
$ echo b >>a
$ git commit -am 'Something'
[master 6732d81] Something
1 files changed, 1 insertions(+), 0 deletions(-)
$ git notes append -m 'Side'
$ git rebase -i HEAD~2 # Will squash the last commit into the one before and accept the default commit message.
[detached HEAD 552668b] Something
1 files changed, 2 insertions(+), 0 deletions(-)
Successfully rebased and updated refs/heads/master.
$ git show
commit 552668b4b96e4b2f8fcd7763dcc115edd159eb89 (HEAD, master)
Author: me_and <not.an@email.address>
Date: Wed Jan 30 10:09:10 2013 +0000
Something
Something
Notes:
Dark
Side
diff --git a/a b/a
index 7898192..4ac2bee 100644
--- a/a
+++ b/a
@@ -1 +1,3 @@
a
+a
+b
Run Code Online (Sandbox Code Playgroud)