How to compare two commits in Bitbucket server

Viewed 3218
1 Answers

The https://bitbucket.org/OWNER/PROJECT/branches/compare/commit2..commit1 not supported on Bitbucket Server.

You can use REST API that utilizes to diff arbitrary commits. Here is the documentation on that REST API endpoint.

The command line for diffs is: "git diff A B", where it shows the changes from A to B. The 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/?since=A&until=B. Write the file path you want the diff for after "/diff/" and before "?since".

Example:

https://mybitbucket.com/rest/api/latest/projects/STASH/repos/stash/changes?since=689fcf1017dc944ab976433a9ead8f2912d83622&until=a222a1f58c17f9164eb498eeaadde94675a49467}}

https://mybitbucket.com/rest/api/latest/projects/STASH/repos/stash/diff/dao-impl/src/main/java/com/atlassian/stash/internal/pull/HibernateRescopeRequestDao.java?since=689fcf1017dc944ab976433a9ead8f2912d83622&until=a222a1f58c17f9164eb498eeaadde94675a49467

You will have to include a path after {{/diff}}. You can't just ask for the entire diff.

Related