Azure devops API - Get diff between two branches

Viewed 731

How would you compare two branches in Azure repository and fetch the ahead and/or behind commits ?

Ideally using the Azure API and or C#.

1 Answers

You can start with the Azure DevOPs API Diff

GET https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/diffs/commits?api-version=6.0

Example between branches:

GET https://dev.azure.com/fabrikam/MyProject/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/diffs/commits?baseVersion=develop&targetVersion=master&api-version=6.0

Once a simple curl is working, you can encapsulate it in a C# program, or check the Azure DevOps .NET client libraries

Related