【问题标题】:How can I set special chars in the git log --pretty=format?如何在 git log --pretty=format 中设置特殊字符?
【发布时间】:2015-07-03 07:33:38
【问题描述】:

我正在学习 Git。我写了命令:

$ git log --pretty=format:"author: %an, %ae\ncommiter: %cn, %ce\nInfo: %s"

我预计\n 会被解释为换行符:

author: CharliePoole, charliepoole@gmail.com
commiter: CharliePoole, charliepoole@gmail.com
Info: Merge pull request #563 from nunit/issue-562

但是我得到了这个输出:

作者:CharliePoole,charliepoole@gmail.com\n提交人: CharliePoole,
charliepoole@gmail.com\n信息:合并拉取请求 #563 来自 nunit/issue-562

我也读过这个before

转义 strings 不是 Git 的工作; git log 什么都没有 这将帮助你做到这一点。

那么,转义字符也是不可能的吗?

【问题讨论】:

    标签: git


    【解决方案1】:

    你正在混合两种不同的东西。来自man git

    格式:格式允许您指定要显示的信息。它的工作方式有点像 printf 格式,但值得注意的例外是你得到一个换行符,换行符是 %n 而不是 \n。

    答案:使用%n

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-06
      • 2010-11-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多