git - 如何在 git 中对齐列以改进格式?

标签 git format git-branch

我想改进我的“git branch”命令的格式,在那里我添加了逻辑以包含 提交日期 提交用户 .

git for-each-ref refs/heads/ --format='%(HEAD) %(color:bold yellow)%(refname:short)%(color:reset) %(color:green)%(committerdate)%(color:reset) - %(contents:subject) %(color:dim white) - %(authorname)%(color:reset)'



enter image description here

无论如何,是否可以将格式从第一个(实际)输出改进为第二个(所需)输出?

这根本不是一件紧急的事情,而是一件很高兴的事情。我玩过 git 格式,但我的知识有限。

最佳答案

我建议使用 %(align)格式选项,像这样:

%(align:width=<number of chars>) <column to align> %(end)

在你的例子中会给出
git for-each-ref refs/heads/ --format='%(HEAD) %(align:width=15)%(color:bold yellow)%(refname:short)%(end)%(color:reset) %(color:green)%(committerdate)%(color:reset) - %(contents:subject) %(color:dim white) - %(authorname)%(color:reset)'

尽管没有为对齐提供动态值,但它确实可以完成工作,这很好,但可能没有必要,具体取决于您的上下文。

关于git - 如何在 git 中对齐列以改进格式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60852089/

相关文章:

git - 推送被拒绝,未检测到 Cedar 支持的应用程序

git - 恢复没有分支的提交

html - IE 中的这种表格格式有什么问题?

git - 为什么这个恢复失败了?

git - 什么时候删除 Git 中的分支?

python - 在主分支 merge 时更改 Python 包版本

git:在子目录中放置一个分支

python - 如何从 gae 本地主机服务器下载数据到 b.csv,类似于 a.csv 格式

perl - 以Perl格式书写时如何使用Unicode字符?

git - 将更改的文件从功能 merge 到修补程序 git 流