例如:

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

最佳答案

问题几乎可以肯定是您的配置。假设您具有其他默认配置,则需要将notes.rewriteRef选项设置为refs/notes/commits才能起作用。

因此,您需要的魔术命令是:

git config notes.rewriteRef refs/notes/commits

在完成上述操作之后,压缩提交应该将这两个注释 merge 在一起。

但是,它们之间会有换行符。我怀疑禁用该行为,以便使您的代码与示例中的内容相同,这需要在Git源代码中进行破解。

背景

git help config (重点是我):



(另请参见notes.rewriteModenotes.rewrite.<command>的描述,这两个默认值都是我们需要的值,即分别为concatenatetrue。)

例子

这与上述测试类似:
$ 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 <[email protected]>
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

关于git - 如果这些笔记的提交被压缩,是否有一种自动 merge 笔记的方法?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/14585613/

10-14 06:28