GET /projects/:id/repository/commits/:sha/diff

I am trying to get the diff between two tags with this api: GET /projects/:id/repository/commits/:sha/diff

Say I have these tags:
tag1
tag2
tag3
tag4

If I do

GET /projects/:id/repository/commits/tag2/diff

the api returns the diff between tag1 and tag2, similar to “git diff tag1 tag2”. How do I use the api to perform “git diff tag1 tag3” or “git diff tag1…tag2”?

You could try https://docs.gitlab.com/ee/api/repositories.html#compare-branches-tags-or-commits.

1 Like

Thank you alexk. That was it! I posted another question where you might be able to help me too. Here’s the link: How to emulate git status using the GitLab API

I may be missing something, but the compare page does not seem to offer a way to download a diff.