我有一个提交,其中包含类似
[Hello World]Something.
Subject: [PATCH 1/7] [Hello World] Something.
但是当我使用 git am 打补丁后,提交信息就变成了“Something”,[Hello World] 似乎丢失了。
打补丁后如何保留“[]”中的内容?
git am -k
会阻止它删除主题开头的 []
括号中的内容,但这也会保留 [PATCH 1/7]
部分。 git format-patch
还有一个 -k
选项,可以防止它添加此类内容,从而允许通过 git format-patch | git am
循环保留主题。
我也有同样的担忧,并在下面的链接中找到了解决方案:
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".