How to diff arbitrary commits using REST API

Still need help?

The Atlassian Community is here for you.

Ask the community


BSERV-2550 - Getting issue details... STATUS

There currently aren't any good ways of diffing arbitrary commits in Bitbucket Server's UI.  We have a Feature request BSERV-2550 which addresses this. It's possible to tag commits that you wish to diff and then create a pull request and selecting tags instead of branches, but REST API is also an option. The following may be useful for those who don't like the tag option and also plugin developers. 


Diff Two Commits

  • The command line for diffs is: "git diff A B", where it shows the changes from A to B. Our REST URL looks like /rest/api/latest/projects/KEY/repos/slug/changes?since=A&until=B (where A and B have the same relevance). That will list all the files that changed.

    You can call /rest/api/latest/projects/KEY/repos/slug/diff/<one file>?since=A&until=B. Write the file path you want the diff for after /diff/ and before ?since.

  • You will have to include a path after /diff. You can't just ask for the entire diff
    So something like this will return a 400 Bad Request:



Last modified on Feb 19, 2016

Was this helpful?

Provide feedback about this article
Powered by Confluence and Scroll Viewport.