Reputation: 5443
This is surely something simple I'm overlooking. In the Azure DevOps web interface (not integrated as part of an IDE), I see how to compare any commit to its parent, but I can't figure out how to compare it to an arbitrary commit.
ie, I'm looking for the equivalent of GitHub's compare/hash1..hash2 functionality.
The appeal is that the web UI is a view/tool common to everyone, and presumably I could get a link to the specific diff I'm interested in and share it with colleagues.
The web UI suggests it might be possible because when viewing the changes for a particular commit it has text Diff to Parent 1 - <my commit hash>
but I haven't figured out how to change Parent 1
.
Upvotes: 143
Views: 98240
Reputation: 19
Construct the URL Manually:
https://dev.azure.com/{organization}/{project}/_git/{repository}/branchCompare?baseVersion=GC{commitA}&targetVersion=GC{commitB}&_a=files
You specify the source base and target version in the URL query string.
Also, you can mix and match versions
Once you entered the URL and load the page you will see a full diff views that list all file changes between the two commits.
Upvotes: 0
Reputation: 1
If you would like to compare two commits of a branch...
Upvotes: -2
Reputation: 30463
The Devops UI does now allow a comparison of the commits between branches as well as files. The URL is very similar to the one detailed in George Heylar's answer, you just change the end of the URL from 'files' to 'commits':
Select 'Set as default branch'
Repeat the same process for the second branch you want to compare to:
This time select Select 'Set as compare branch'
Finally open the ellipsis menu again for the branch you set as the default branch (i.e. the one you picked in step 3 above)
Upvotes: 18
Reputation: 5288
If you go to the list of branches for a repository, you can click on ...
(More Actions) on one of the branches and choose Compare branches
This will take you to a URL in the form:
https://dev.azure.com/{organisation}/{project}/_git/{repository}/branches?baseVersion=GB{baseBranch}&targetVersion=GB{targetBranch}&_a=files
You can then change the baseVersion
and targetVersion
parameters in the query string. These can take the following forms, and can be mixed and matched:
GB{branchName}
GC{commitHash}
GT{tagName}
Just in case that link gets broken, clicking "View Merge Changes" on a pull request takes you to the same page but with a slightly different URL https://dev.azure.com/{organisation}/{project}/_git/{repository}/branchCompare?baseVersion=GC{baseCommit}&targetVersion=GC{targetCommit}&_a=files
I'm not sure if there's a nicer way of comparing commits from the UI, as it only shows branches and tags, but if you do it this way you don't have to temporarily tag commits or create temporary branches just to get a diff that shows all of the changed files.
Upvotes: 228
Reputation: 19451
If you want to compare two arbitrary commits for one file, navigate to the file in the repo, select the compare tab, and apply the appropriate commit range.
If you want to compare two arbitrary commits for all files , you can create tags at commits , then compare them. This will give you a list of commits between them and allow you to show the diffs.
For details, you can refer to this case.
Upvotes: 44
Reputation: 1326882
The "Diff to Parent 1" feature is described in "Commit details / What are the changes included in the commit?"
Diff to parent - Click on Diff on parent1 in the Source Explorer pane to view the difference between the current commit and its parent commit.
One can see what Parent1 references in the diff view itself:
But I don't see any web URL which could help reference that diff. Hence my initial Azure DevOps Git API that I proposed before.
Upvotes: 1