Github API - How can I see the Diff of a File in the Repo?

Viewed 140

I just wanted to see the diff of a file in the Repo - for example, want to see the difference of the file between July 1st and July 15th.

I was trying to do below -

  1. get the commit ID of the file which was committed on July 1st 0:00
  2. get the commit ID of the file which was committed on July 15th 0:00
  3. use compare-two-commits API to compare above #1 commit and #2 commit

Actually above doesn't work, if those commits contains over 300 files changes due to the limitation of compare-two-commits API. Since our Repo contains more than 30K files, it happens very often that one commit contains >300 files changes.

I tried to search this in Github API reference, but I couldn't find.

So if there is the way to get the diff of one file in a Repo (let's say between now and half month ago), that would be really great.

1 Answers
git log -p --since=01.07.2021 --before=16.07.2021 <filename>

this works for me, it gives you a history of all commits in the given date range

or alternative, if you want to compare two commits directly with each other you can use

git diff <commit-id> <commit-id> -- <filename>
Related