0

I know there have been answers for seeing the diff in the full file, but I wish to diff two online files.

I have a large list of commit hashes from public repositories. I wish to automate collecting the unified diff with the rest of the unchanged file. However, GitHub's diff viewer only shows the area around the changed lines. How can I see the diff, online, in context of the whole file?

Queso Pez
  • 123
  • 5
  • What have you tried so far? GitHub has a flexible API, for fetch file contents directly from the repositories you might want to look at the [repository contents api](https://docs.github.com/en/rest/repos/contents); you can use that to request the contents of a file from a given commit. – larsks Aug 08 '22 at 22:46
  • @larsks I tried navigating to the repo/commit/.diff, but it still only gave me a few lines. I suppose I could get the file contents before and after the commit and use some tool to diff them, but if there were a direct way to get the diff it would be easier. – Queso Pez Aug 08 '22 at 22:55
  • 1
    Navigating to `.../.diff` gives you the complete *diff*, which of course won't include all the lines in the file (unless you happened to be adding a new file in that commit). Unfortunately, if you're trying to compare a particular file between two revisions, that probably won't do you any good. For that, I think you fetch the file content using the API I mentioned in my last comment and then generate the diff yourself. – larsks Aug 08 '22 at 23:05

0 Answers0