我想改进我的“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)'
无论如何,是否可以将格式从第一个(实际)输出改进为第二个(所需)输出?
这根本不是一件紧急的事情,而是一件很高兴的事情。我玩过 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/