【发布时间】:2018-05-26 19:53:55
【问题描述】:
我有一个 Git 提交,它有一个摘要,然后是一些描述。所以当我通过git log --format=%B -n 1 <commit> 看到提交消息时,它看起来像这样:
Commit Summary Line
* Commit Description Line 1
* Commit Description Line 2
* Commit Description Line 3
但是,当我尝试将其存储在 Bash 变量中时:
message=$(git log --format=%B -n 1 <commit>)
然后我尝试echo $message,我从当前目录中获取文件夹名称与提交消息中的每一行混合。更重要的是,我什至没有看到提交消息中的所有行,只是其中的一些。所以,$message 看起来像这样:
Commit Summary Line folder1 folder2 folder3 Commit Description Line 1 folder1 folder2 folder3 Commit Description Line 3
对这种行为有什么解释吗?我只希望$message 包含完整提交消息中的所有行。我什至不在乎它们是在新行中还是全部在一行中,我只想将所有行都存储在字符串变量中。我如何做到这一点?
【问题讨论】:
-
正如我常说的,当有疑问时...引用它!
标签: git bash github git-commit