Compare two commits

GET {{baseUrl}}/repos/:owner/:repo/compare/{{base}}...{{head}}

Both :base and :head must be branch names in :repo. To compare branches across other repositories in the same network as :repo, use the format <USERNAME>:branch.

The response from the API is equivalent to running the git log base..head command; however, commits are returned in chronological order. Pass the appropriate media type to fetch diff and patch formats.

The response also includes details on the files that were changed between the two commits. This includes the status of the change (for example, if a file was added, removed, modified, or renamed), and details of the change itself. For example, files with a renamed status have a previous_filename field showing the previous filename of the file, and files with a modified status have a patch field showing the changes made to the file.

Working with large comparisons

The response will include a comparison of up to 250 commits. If you are working with a larger commit range, you can use the List commits to enumerate all commits in the range.

For comparisons with extremely large diffs, you may receive an error response indicating that the diff took too long to generate. You can typically resolve this error by using a smaller commit range.

Signature verification object

The response will include a verification object that describes the result of verifying the commit's signature. The following fields are included in the verification object:

These are the possible values for reason in the verification object:

ValueDescription
expired_keyThe key that made the signature is expired.
not_signing_keyThe signing flag is not among the usage flags in the GPG key that made the signature.
gpgverify_errorThere was an error communicating with the signature verification service.
gpgverify_unavailableThe signature verification service is currently unavailable.
unsignedThe object does not include a signature.
unknown_signature_typeA non-PGP signature was found in the commit.
no_userNo user was associated with the committer email address in the commit.
unverified_emailThe committer email address in the commit was associated with a user, but the email address is not verified on her/his account.
bad_emailThe committer email address in the commit is not included in the identities of the PGP key that made the signature.
unknown_keyThe key that made the signature has not been registered with any user's account.
malformed_signatureThere was an error parsing the signature.
invalidThe signature could not be cryptographically verified using the key whose key-id was found in the signature.
validNone of the above errors applied, so the signature is considered to be verified.

RESPONSES

status: OK

{&quot;url&quot;:&quot;https://api.github.com/repos/octocat/Hello-World/compare/master...topic&quot;,&quot;html_url&quot;:&quot;https://github.com/octocat/Hello-World/compare/master...topic&quot;,&quot;permalink_url&quot;:&quot;https://github.com/octocat/Hello-World/compare/octocat:bbcd538c8e72b8c175046e27cc8f907076331401...octocat:0328041d1152db8ae77652d1618a02e57f745f17&quot;,&quot;diff_url&quot;:&quot;https://github.com/octocat/Hello-World/compare/master...topic.diff&quot;,&quot;patch_url&quot;:&quot;https://github.com/octocat/Hello-World/compare/master...topic.patch&quot;,&quot;base_commit&quot;:{&quot;url&quot;:&quot;https://api.github.com/repos/octocat/Hello-World/commits/6dcb09b5b57875f334f61aebed695e2e4193db5e&quot;,&quot;sha&quot;:&quot;6dcb09b5b57875f334f61aebed695e2e4193db5e&quot;,&quot;node_id&quot;:&quot;MDY6Q29tbWl0NmRjYjA5YjViNTc4NzVmMzM0ZjYxYWViZWQ2OTVlMmU0MTkzZGI1ZQ==&quot;,&quot;html_url&quot;:&quot;https://github.com/octocat/Hello-World/commit/6dcb09b5b57875f334f61aebed695e2e4193db5e&quot;,&quot;comments_url&quot;:&quot;https://api.github.com/repos/octocat/Hello-World/commits/6dcb09b5b57875f334f61aebed695e2e4193db5e/comments&quot;,&quot;commit&quot;:{&quot;url&quot;:&quot;https://api.github.com/repos/octocat/Hello-World/git/commits/6dcb09b5b57875f334f61aebed695e2e4193db5e&quot;,&quot;author&quot;:{&quot;name&quot;:&quot;Monalisa Octocat&quot;,&quot;email&quot;:&quot;mona@github.com&quot;,&quot;date&quot;:&quot;2011-04-14T16:00:49Z&quot;},&quot;committer&quot;:{&quot;name&quot;:&quot;Monalisa Octocat&quot;,&quot;email&quot;:&quot;mona@github.com&quot;,&quot;date&quot;:&quot;2011-04-14T16:00:49Z&quot;},&quot;message&quot;:&quot;Fix all the bugs&quot;,&quot;tree&quot;:{&quot;url&quot;:&quot;https://api.github.com/repos/octocat/Hello-World/tree/6dcb09b5b57875f334f61aebed695e2e4193db5e&quot;,&quot;sha&quot;:&quot;6dcb09b5b57875f334f61aebed695e2e4193db5e&quot;},&quot;comment_count&quot;:0,&quot;verification&quot;:{&quot;verified&quot;:false,&quot;reason&quot;:&quot;unsigned&quot;,&quot;signature&quot;:null,&quot;payload&quot;:null}},&quot;author&quot;:{&quot;login&quot;:&quot;octocat&quot;,&quot;id&quot;:1,&quot;node_id&quot;:&quot;MDQ6VXNlcjE=&quot;,&quot;avatar_url&quot;:&quot;https://github.com/images/error/octocat_happy.gif&quot;,&quot;gravatar_id&quot;:&quot;&quot;,&quot;url&quot;:&quot;https://api.github.com/users/octocat&quot;,&quot;html_url&quot;:&quot;https://github.com/octocat&quot;,&quot;followers_url&quot;:&quot;https://api.github.com/users/octocat/followers&quot;,&quot;following_url&quot;:&quot;https://api.github.com/users/octocat/following{/other_user}&quot;,&quot;gists_url&quot;:&quot;https://api.github.com/users/octocat/gists{/gist_id}&quot;,&quot;starred_url&quot;:&quot;https://api.github.com/users/octocat/starred{/owner}{/repo}&quot;,&quot;subscriptions_url&quot;:&quot;https://api.github.com/users/octocat/subscriptions&quot;,&quot;organizations_url&quot;:&quot;https://api.github.com/users/octocat/orgs&quot;,&quot;repos_url&quot;:&quot;https://api.github.com/users/octocat/repos&quot;,&quot;events_url&quot;:&quot;https://api.github.com/users/octocat/events{/privacy}&quot;,&quot;received_events_url&quot;:&quot;https://api.github.com/users/octocat/received_events&quot;,&quot;type&quot;:&quot;User&quot;,&quot;site_admin&quot;:false},&quot;committer&quot;:{&quot;login&quot;:&quot;octocat&quot;,&quot;id&quot;:1,&quot;node_id&quot;:&quot;MDQ6VXNlcjE=&quot;,&quot;avatar_url&quot;:&quot;https://github.com/images/error/octocat_happy.gif&quot;,&quot;gravatar_id&quot;:&quot;&quot;,&quot;url&quot;:&quot;https://api.github.com/users/octocat&quot;,&quot;html_url&quot;:&quot;https://github.com/octocat&quot;,&quot;followers_url&quot;:&quot;https://api.github.com/users/octocat/followers&quot;,&quot;following_url&quot;:&quot;https://api.github.com/users/octocat/following{/other_user}&quot;,&quot;gists_url&quot;:&quot;https://api.github.com/users/octocat/gists{/gist_id}&quot;,&quot;starred_url&quot;:&quot;https://api.github.com/users/octocat/starred{/owner}{/repo}&quot;,&quot;subscriptions_url&quot;:&quot;https://api.github.com/users/octocat/subscriptions&quot;,&quot;organizations_url&quot;:&quot;https://api.github.com/users/octocat/orgs&quot;,&quot;repos_url&quot;:&quot;https://api.github.com/users/octocat/repos&quot;,&quot;events_url&quot;:&quot;https://api.github.com/users/octocat/events{/privacy}&quot;,&quot;received_events_url&quot;:&quot;https://api.github.com/users/octocat/received_events&quot;,&quot;type&quot;:&quot;User&quot;,&quot;site_admin&quot;:false},&quot;parents&quot;:[{&quot;url&quot;:&quot;https://api.github.com/repos/octocat/Hello-World/commits/6dcb09b5b57875f334f61aebed695e2e4193db5e&quot;,&quot;sha&quot;:&quot;6dcb09b5b57875f334f61aebed695e2e4193db5e&quot;}]},&quot;merge_base_commit&quot;:{&quot;url&quot;:&quot;https://api.github.com/repos/octocat/Hello-World/commits/6dcb09b5b57875f334f61aebed695e2e4193db5e&quot;,&quot;sha&quot;:&quot;6dcb09b5b57875f334f61aebed695e2e4193db5e&quot;,&quot;node_id&quot;:&quot;MDY6Q29tbWl0NmRjYjA5YjViNTc4NzVmMzM0ZjYxYWViZWQ2OTVlMmU0MTkzZGI1ZQ==&quot;,&quot;html_url&quot;:&quot;https://github.com/octocat/Hello-World/commit/6dcb09b5b57875f334f61aebed695e2e4193db5e&quot;,&quot;comments_url&quot;:&quot;https://api.github.com/repos/octocat/Hello-World/commits/6dcb09b5b57875f334f61aebed695e2e4193db5e/comments&quot;,&quot;commit&quot;:{&quot;url&quot;:&quot;https://api.github.com/repos/octocat/Hello-World/git/commits/6dcb09b5b57875f334f61aebed695e2e4193db5e&quot;,&quot;author&quot;:{&quot;name&quot;:&quot;Monalisa Octocat&quot;,&quot;email&quot;:&quot;mona@github.com&quot;,&quot;date&quot;:&quot;2011-04-14T16:00:49Z&quot;},&quot;committer&quot;:{&quot;name&quot;:&quot;Monalisa Octocat&quot;,&quot;email&quot;:&quot;mona@github.com&quot;,&quot;date&quot;:&quot;2011-04-14T16:00:49Z&quot;},&quot;message&quot;:&quot;Fix all the bugs&quot;,&quot;tree&quot;:{&quot;url&quot;:&quot;https://api.github.com/repos/octocat/Hello-World/tree/6dcb09b5b57875f334f61aebed695e2e4193db5e&quot;,&quot;sha&quot;:&quot;6dcb09b5b57875f334f61aebed695e2e4193db5e&quot;},&quot;comment_count&quot;:0,&quot;verification&quot;:{&quot;verified&quot;:false,&quot;reason&quot;:&quot;unsigned&quot;,&quot;signature&quot;:null,&quot;payload&quot;:null}},&quot;author&quot;:{&quot;login&quot;:&quot;octocat&quot;,&quot;id&quot;:1,&quot;node_id&quot;:&quot;MDQ6VXNlcjE=&quot;,&quot;avatar_url&quot;:&quot;https://github.com/images/error/octocat_happy.gif&quot;,&quot;gravatar_id&quot;:&quot;&quot;,&quot;url&quot;:&quot;https://api.github.com/users/octocat&quot;,&quot;html_url&quot;:&quot;https://github.com/octocat&quot;,&quot;followers_url&quot;:&quot;https://api.github.com/users/octocat/followers&quot;,&quot;following_url&quot;:&quot;https://api.github.com/users/octocat/following{/other_user}&quot;,&quot;gists_url&quot;:&quot;https://api.github.com/users/octocat/gists{/gist_id}&quot;,&quot;starred_url&quot;:&quot;https://api.github.com/users/octocat/starred{/owner}{/repo}&quot;,&quot;subscriptions_url&quot;:&quot;https://api.github.com/users/octocat/subscriptions&quot;,&quot;organizations_url&quot;:&quot;https://api.github.com/users/octocat/orgs&quot;,&quot;repos_url&quot;:&quot;https://api.github.com/users/octocat/repos&quot;,&quot;events_url&quot;:&quot;https://api.github.com/users/octocat/events{/privacy}&quot;,&quot;received_events_url&quot;:&quot;https://api.github.com/users/octocat/received_events&quot;,&quot;type&quot;:&quot;User&quot;,&quot;site_admin&quot;:false},&quot;committer&quot;:{&quot;login&quot;:&quot;octocat&quot;,&quot;id&quot;:1,&quot;node_id&quot;:&quot;MDQ6VXNlcjE=&quot;,&quot;avatar_url&quot;:&quot;https://github.com/images/error/octocat_happy.gif&quot;,&quot;gravatar_id&quot;:&quot;&quot;,&quot;url&quot;:&quot;https://api.github.com/users/octocat&quot;,&quot;html_url&quot;:&quot;https://github.com/octocat&quot;,&quot;followers_url&quot;:&quot;https://api.github.com/users/octocat/followers&quot;,&quot;following_url&quot;:&quot;https://api.github.com/users/octocat/following{/other_user}&quot;,&quot;gists_url&quot;:&quot;https://api.github.com/users/octocat/gists{/gist_id}&quot;,&quot;starred_url&quot;:&quot;https://api.github.com/users/octocat/starred{/owner}{/repo}&quot;,&quot;subscriptions_url&quot;:&quot;https://api.github.com/users/octocat/subscriptions&quot;,&quot;organizations_url&quot;:&quot;https://api.github.com/users/octocat/orgs&quot;,&quot;repos_url&quot;:&quot;https://api.github.com/users/octocat/repos&quot;,&quot;events_url&quot;:&quot;https://api.github.com/users/octocat/events{/privacy}&quot;,&quot;received_events_url&quot;:&quot;https://api.github.com/users/octocat/received_events&quot;,&quot;type&quot;:&quot;User&quot;,&quot;site_admin&quot;:false},&quot;parents&quot;:[{&quot;url&quot;:&quot;https://api.github.com/repos/octocat/Hello-World/commits/6dcb09b5b57875f334f61aebed695e2e4193db5e&quot;,&quot;sha&quot;:&quot;6dcb09b5b57875f334f61aebed695e2e4193db5e&quot;}]},&quot;status&quot;:&quot;behind&quot;,&quot;ahead_by&quot;:1,&quot;behind_by&quot;:2,&quot;total_commits&quot;:1,&quot;commits&quot;:[{&quot;url&quot;:&quot;https://api.github.com/repos/octocat/Hello-World/commits/6dcb09b5b57875f334f61aebed695e2e4193db5e&quot;,&quot;sha&quot;:&quot;6dcb09b5b57875f334f61aebed695e2e4193db5e&quot;,&quot;node_id&quot;:&quot;MDY6Q29tbWl0NmRjYjA5YjViNTc4NzVmMzM0ZjYxYWViZWQ2OTVlMmU0MTkzZGI1ZQ==&quot;,&quot;html_url&quot;:&quot;https://github.com/octocat/Hello-World/commit/6dcb09b5b57875f334f61aebed695e2e4193db5e&quot;,&quot;comments_url&quot;:&quot;https://api.github.com/repos/octocat/Hello-World/commits/6dcb09b5b57875f334f61aebed695e2e4193db5e/comments&quot;,&quot;commit&quot;:{&quot;url&quot;:&quot;https://api.github.com/repos/octocat/Hello-World/git/commits/6dcb09b5b57875f334f61aebed695e2e4193db5e&quot;,&quot;author&quot;:{&quot;name&quot;:&quot;Monalisa Octocat&quot;,&quot;email&quot;:&quot;mona@github.com&quot;,&quot;date&quot;:&quot;2011-04-14T16:00:49Z&quot;},&quot;committer&quot;:{&quot;name&quot;:&quot;Monalisa Octocat&quot;,&quot;email&quot;:&quot;mona@github.com&quot;,&quot;date&quot;:&quot;2011-04-14T16:00:49Z&quot;},&quot;message&quot;:&quot;Fix all the bugs&quot;,&quot;tree&quot;:{&quot;url&quot;:&quot;https://api.github.com/repos/octocat/Hello-World/tree/6dcb09b5b57875f334f61aebed695e2e4193db5e&quot;,&quot;sha&quot;:&quot;6dcb09b5b57875f334f61aebed695e2e4193db5e&quot;},&quot;comment_count&quot;:0,&quot;verification&quot;:{&quot;verified&quot;:false,&quot;reason&quot;:&quot;unsigned&quot;,&quot;signature&quot;:null,&quot;payload&quot;:null}},&quot;author&quot;:{&quot;login&quot;:&quot;octocat&quot;,&quot;id&quot;:1,&quot;node_id&quot;:&quot;MDQ6VXNlcjE=&quot;,&quot;avatar_url&quot;:&quot;https://github.com/images/error/octocat_happy.gif&quot;,&quot;gravatar_id&quot;:&quot;&quot;,&quot;url&quot;:&quot;https://api.github.com/users/octocat&quot;,&quot;html_url&quot;:&quot;https://github.com/octocat&quot;,&quot;followers_url&quot;:&quot;https://api.github.com/users/octocat/followers&quot;,&quot;following_url&quot;:&quot;https://api.github.com/users/octocat/following{/other_user}&quot;,&quot;gists_url&quot;:&quot;https://api.github.com/users/octocat/gists{/gist_id}&quot;,&quot;starred_url&quot;:&quot;https://api.github.com/users/octocat/starred{/owner}{/repo}&quot;,&quot;subscriptions_url&quot;:&quot;https://api.github.com/users/octocat/subscriptions&quot;,&quot;organizations_url&quot;:&quot;https://api.github.com/users/octocat/orgs&quot;,&quot;repos_url&quot;:&quot;https://api.github.com/users/octocat/repos&quot;,&quot;events_url&quot;:&quot;https://api.github.com/users/octocat/events{/privacy}&quot;,&quot;received_events_url&quot;:&quot;https://api.github.com/users/octocat/received_events&quot;,&quot;type&quot;:&quot;User&quot;,&quot;site_admin&quot;:false},&quot;committer&quot;:{&quot;login&quot;:&quot;octocat&quot;,&quot;id&quot;:1,&quot;node_id&quot;:&quot;MDQ6VXNlcjE=&quot;,&quot;avatar_url&quot;:&quot;https://github.com/images/error/octocat_happy.gif&quot;,&quot;gravatar_id&quot;:&quot;&quot;,&quot;url&quot;:&quot;https://api.github.com/users/octocat&quot;,&quot;html_url&quot;:&quot;https://github.com/octocat&quot;,&quot;followers_url&quot;:&quot;https://api.github.com/users/octocat/followers&quot;,&quot;following_url&quot;:&quot;https://api.github.com/users/octocat/following{/other_user}&quot;,&quot;gists_url&quot;:&quot;https://api.github.com/users/octocat/gists{/gist_id}&quot;,&quot;starred_url&quot;:&quot;https://api.github.com/users/octocat/starred{/owner}{/repo}&quot;,&quot;subscriptions_url&quot;:&quot;https://api.github.com/users/octocat/subscriptions&quot;,&quot;organizations_url&quot;:&quot;https://api.github.com/users/octocat/orgs&quot;,&quot;repos_url&quot;:&quot;https://api.github.com/users/octocat/repos&quot;,&quot;events_url&quot;:&quot;https://api.github.com/users/octocat/events{/privacy}&quot;,&quot;received_events_url&quot;:&quot;https://api.github.com/users/octocat/received_events&quot;,&quot;type&quot;:&quot;User&quot;,&quot;site_admin&quot;:false},&quot;parents&quot;:[{&quot;url&quot;:&quot;https://api.github.com/repos/octocat/Hello-World/commits/6dcb09b5b57875f334f61aebed695e2e4193db5e&quot;,&quot;sha&quot;:&quot;6dcb09b5b57875f334f61aebed695e2e4193db5e&quot;}]}],&quot;files&quot;:[{&quot;sha&quot;:&quot;bbcd538c8e72b8c175046e27cc8f907076331401&quot;,&quot;filename&quot;:&quot;file1.txt&quot;,&quot;status&quot;:&quot;added&quot;,&quot;additions&quot;:103,&quot;deletions&quot;:21,&quot;changes&quot;:124,&quot;blob_url&quot;:&quot;https://github.com/octocat/Hello-World/blob/6dcb09b5b57875f334f61aebed695e2e4193db5e/file1.txt&quot;,&quot;raw_url&quot;:&quot;https://github.com/octocat/Hello-World/raw/6dcb09b5b57875f334f61aebed695e2e4193db5e/file1.txt&quot;,&quot;contents_url&quot;:&quot;https://api.github.com/repos/octocat/Hello-World/contents/file1.txt?ref=6dcb09b5b57875f334f61aebed695e2e4193db5e&quot;,&quot;patch&quot;:&quot;@@ -132,7 +132,7 @@ module Test @@ -1000,7 +1000,7 @@ module Test&quot;}]}