我如何精确地打印出一个git-diff输出? [英] How do I prettily print out a git-diff output?

查看:315
本文介绍了我如何精确地打印出一个git-diff输出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于即将到来的本科毕业论文,我需要打印出本文附录中的git-diff输出。我真的很喜欢 git diff --color-words 的输出,但是我完全不知道如何将这种颜色 - 包括行号 - 带到一张纸上在我的Mac上。我知道有像 SourceTree 这样的工具,但即使那些我似乎无法打印出漂亮的照片单个文件的差异。

那么,我非常肯定,我不能成为唯一的这个问题,我发现了一些建议的ansi2html解决方案,但他们似乎并不使用我的git版本(1.7.10.2)。我还想过简单地打印Github提交页面(这真的很漂亮,看起来像我需要的),但是当我试图打印它时,浏览器会自动删除所有的着色和格式化。



感谢您的帮助!

解决方案使用 aha 。您可以使用 sudo apt-get install aha 在Ubuntu中安装它。另请参阅 https://github.com/theZiz/aha

  $ git diff --color-words | aha> index.html 
$ firefox index.html

然后Firefox应该能够打印它颜色。查看 aha --help 以获取其他一些很酷的选项。


for my upcoming Bachelor thesis, I am required to print out the git-diff output for the appendix of the paper. I really like the output of git diff --color-words, but I have absolutely no idea how to bring this - colored and with line numbers included - to a piece of paper on my Mac. I know there are tools like SourceTree, but even with those I seem not able to make a pretty print out of the single file's diffs.

Well, I am pretty sure that I cannot be the only one with this problem, and I found some suggested ansi2html solutions, but they to not seem to work with my version of git (1.7.10.2). I also thought about simply printing the Github commit page (which is really pretty and kind of looks like what I need), but the browser will automatically remove all coloring and formatting when I am trying to print it.

Thanks for your help!

解决方案

Use aha. You can install it in ubuntu with sudo apt-get install aha. Also see https://github.com/theZiz/aha.

$ git diff --color-words | aha > index.html
$ firefox index.html

Firefox should then be able to print it in color. Check out aha --help for some other cool options.

这篇关于我如何精确地打印出一个git-diff输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆