git am 应该忽略提交消息中以“[]”开头的内容吗?

问题描述 投票:0回答:2

我有一个提交,其中包含类似

[Hello World]Something.

的消息 然后我使用 git format-patch HEAD~1 来创建补丁。
补丁内容如下:

Subject: [PATCH 1/7] [Hello World] Something.

但是当我使用 git am 打补丁后,提交信息就变成了“Something”,[Hello World] 似乎丢失了。
打补丁后如何保留“[]”中的内容?

git git-am
2个回答
13
投票

git am -k
会阻止它删除主题开头的
[]
括号中的内容,但这也会保留
[PATCH 1/7]
部分。
git format-patch
还有一个
-k
选项,可以防止它添加此类内容,从而允许通过
git format-patch | git am
循环保留主题。


5
投票

我也有同样的担忧,并在下面的链接中找到了解决方案:

Bug:在 git-am 中不正确地剥离 [PATCH] 前缀

我们必须使用带有“--keep-non-patch”选项的“am”命令。手册页描述如下:

$ 男人 git am

   --keep-non-patch
       Pass -b flag to git mailinfo (see git-mailinfo(1)).

$ man git 邮件信息

   -b
       When -k is not in effect, all leading strings bracketed with [ and ] pairs
       are stripped.  This option limits the stripping to only the pairs whose
       bracketed string contains the word "PATCH".
© www.soinside.com 2019 - 2024. All rights reserved.