git am应该忽略提交消息中的某些内容以"[]"开头?

Sun*_*nny 8 git git-am

我有一个提交消息,[Hello World]Something.
然后我使用git format-patch HEAD~1来修补补丁.
像这样的补丁内容:

Subject: [PATCH 1/7] [Hello World] Something.
Run Code Online (Sandbox Code Playgroud)

但是在我使用git am应用补丁之后,提交消息只变成了"Something",[Hello World]似乎丢失了.
应用补丁后,如何在"[]"中保留内容?

qqx*_*qqx 11

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


小智 5

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

http://git.661346.n2.nabble.com/Bug-In Correct-stripping-of-the-PATCH-prefix-in-git-am-td7643405.html

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

$ man git am

   --keep-non-patch
       Pass -b flag to git mailinfo (see git-mailinfo(1)).
Run Code Online (Sandbox Code Playgroud)

$ 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".
Run Code Online (Sandbox Code Playgroud)