Search code examples
gitpdf-generationgit-blame

export git blame to PDF or HTML


Is there a programmatic way to export git blame from a (text) file to either PDF (preferred) or HTML?

I know that github already offers a blame view in webbrowser (see e.g. here), but in the end I want to do a blame-export for all files in a given repository.


Solution

  • Since git doesn't offer that itself I ended up with @terrorrussia-keeps-killing comment and wrote a python script:

    1. run git blame --line-porcelain <sha1> -- <fname>
    2. parse the output
    3. generate HTML with jinja2 (see e.g. this tutorial) and save to .html file

    (the source is copyright-