英文:
Git: Print a hashtag in a custom log format
问题
我如下提供翻译:
如何创建一个自定义日志格式,其中行的开头有一个井号(#)?
我已经在我的git别名中使用破折号获得了我想要的格式:
lpr = log -10 --reverse --format=format:'- %Cgreen %s%n%Creset%b'
问题显然是#是注释,应该被转义。我找不到如何做到这一点。
最终目标是能够创建Markdown格式的日志消息,其中第一行是标题。
英文:
How can I create a custom log format where the start of the line has a hashtag (#)
I have already the format I want with a dash in my git aliases:
lpr = log -10 --reverse --format=format:'- %Cgreen %s%n%Creset%b'
The problem clearly is that # is the comment and should be escaped. I don't find how that is done.
The final goal is to be able to create markdown formatted log messages where the first line is a title.
答案1
得分: 1
I just tested the git alias with a #
, and it seems to work as expected:
C:\my\repo>git config alias.lpr "log -10 --reverse --format=format:'- %Cgreen # %s%n%Creset%b'"
C:\my\repo>git lpr
- # Subject commit 3
Body 3
- # Subject commit 2
Body 2
- # Subject commit 1
Body 1
The strong quotes 'log ... # ...'
means you do not have to escape the #
.
Rendered markdown:
Meaning
英文:
I just tested the git alias with a #
, and it seems to work as expected:
C:\my\repo>git config alias.lpr "log -10 --reverse --format=format:'- %Cgreen # %s%n%Creset%b'"
C:\my\repo>git lpr
- # Subject commit 3
Body 3
- # Subject commit 2
Body 2
- # Subject commit 1
Body 1
The strong quotes 'log ... # ...'
means you do not have to escape the #
.
Rendered markdown:
Meaning
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论