Commits - Get

Retrieve a particular commit.

GET https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/commits/{commitId}?api-version=5.0
GET https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/commits/{commitId}?changeCount={changeCount}&api-version=5.0

URI Parameters

Name In Required Type Description
commitId
path True

string

The id of the commit.

organization
path True

string

The name of the Azure DevOps organization.

repositoryId
path True

string

The id or friendly name of the repository. To use the friendly name, projectId must also be specified.

project
path

string

Project ID or project name

api-version
query True

string

Version of the API to use. This should be set to '5.0' to use this version of the api.

changeCount
query

integer

int32

The number of changes to include in the result.

Responses

Name Type Description
200 OK

GitCommit

successful operation

Security

oauth2

Type: oauth2
Flow: accessCode
Authorization URL: https://app.vssps.visualstudio.com/oauth2/authorize&response_type=Assertion
Token URL: https://app.vssps.visualstudio.com/oauth2/token?client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer&grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer

Scopes

Name Description
vso.code Grants the ability to read source code and metadata about commits, changesets, branches, and other version control artifacts. Also grants the ability to search code and get notified about version control events via service hooks.

Examples

Get by ID
With limited changes

Get by ID

Sample request

GET https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/commits/be67f8871a4d2c75f13a51c1d3c30ac0d74d4ef4?api-version=5.0

Sample response

{
  "parents": [],
  "treeId": "7fa1a3523ffef51c525ea476bffff7d648b8cb3d",
  "push": {
    "pushedBy": {
      "id": "8c8c7d32-6b1b-47f4-b2e9-30b477b5ab3d",
      "displayName": "Chuck Reinhart",
      "uniqueName": "fabrikamfiber3@hotmail.com",
      "url": "https://vssps.dev.azure.com/fabrikam/_apis/Identities/8c8c7d32-6b1b-47f4-b2e9-30b477b5ab3d",
      "imageUrl": "https://dev.azure.com/fabrikam/_api/_common/identityImage?id=8c8c7d32-6b1b-47f4-b2e9-30b477b5ab3d"
    },
    "pushId": 1,
    "date": "2014-01-29T23:33:15.2434002Z"
  },
  "commitId": "be67f8871a4d2c75f13a51c1d3c30ac0d74d4ef4",
  "author": {
    "name": "Chuck Reinhart",
    "email": "fabrikamfiber3@hotmail.com",
    "date": "2014-01-29T23:32:09Z"
  },
  "committer": {
    "name": "Chuck Reinhart",
    "email": "fabrikamfiber3@hotmail.com",
    "date": "2014-01-29T23:32:09Z"
  },
  "comment": "First cut\n",
  "url": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/commits/be67f8871a4d2c75f13a51c1d3c30ac0d74d4ef4",
  "remoteUrl": "https://dev.azure.com/fabrikam/_git/Fabrikam-Fiber-Git/commit/be67f8871a4d2c75f13a51c1d3c30ac0d74d4ef4",
  "_links": {
    "self": {
      "href": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/commits/be67f8871a4d2c75f13a51c1d3c30ac0d74d4ef4"
    },
    "repository": {
      "href": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249"
    },
    "changes": {
      "href": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/commits/be67f8871a4d2c75f13a51c1d3c30ac0d74d4ef4/changes"
    },
    "web": {
      "href": "https://dev.azure.com/fabrikam/_git/Fabrikam-Fiber-Git/commit/be67f8871a4d2c75f13a51c1d3c30ac0d74d4ef4"
    },
    "tree": {
      "href": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/trees/7fa1a3523ffef51c525ea476bffff7d648b8cb3d"
    }
  }
}

With limited changes

Sample request

GET https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/commits/be67f8871a4d2c75f13a51c1d3c30ac0d74d4ef4?changeCount=10&api-version=5.0

Sample response

{
  "parents": [],
  "treeId": "7fa1a3523ffef51c525ea476bffff7d648b8cb3d",
  "push": {
    "pushedBy": {
      "id": "8c8c7d32-6b1b-47f4-b2e9-30b477b5ab3d",
      "displayName": "Chuck Reinhart",
      "uniqueName": "fabrikamfiber3@hotmail.com",
      "url": "https://vssps.dev.azure.com/fabrikam/_apis/Identities/8c8c7d32-6b1b-47f4-b2e9-30b477b5ab3d",
      "imageUrl": "https://dev.azure.com/fabrikam/_api/_common/identityImage?id=8c8c7d32-6b1b-47f4-b2e9-30b477b5ab3d"
    },
    "pushId": 1,
    "date": "2014-01-29T23:33:15.2434002Z"
  },
  "commitId": "be67f8871a4d2c75f13a51c1d3c30ac0d74d4ef4",
  "author": {
    "name": "Chuck Reinhart",
    "email": "fabrikamfiber3@hotmail.com",
    "date": "2014-01-29T23:32:09Z"
  },
  "committer": {
    "name": "Chuck Reinhart",
    "email": "fabrikamfiber3@hotmail.com",
    "date": "2014-01-29T23:32:09Z"
  },
  "comment": "First cut\n",
  "changeCounts": {
    "Add": 456
  },
  "changes": [
    {
      "item": {
        "gitObjectType": "blob",
        "path": "/.gitattributes",
        "url": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/items/.gitattributes?versionType=Commit"
      },
      "changeType": "add"
    },
    {
      "item": {
        "gitObjectType": "blob",
        "path": "/.gitignore",
        "url": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/items/.gitignore?versionType=Commit"
      },
      "changeType": "add"
    },
    {
      "item": {
        "gitObjectType": "tree",
        "path": "/MyWebSite",
        "isFolder": true,
        "url": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/items/MyWebSite?versionType=Commit"
      },
      "changeType": "add"
    },
    {
      "item": {
        "gitObjectType": "tree",
        "path": "/MyWebSite/MyWebSite",
        "isFolder": true,
        "url": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/items/MyWebSite/MyWebSite?versionType=Commit"
      },
      "changeType": "add"
    },
    {
      "item": {
        "gitObjectType": "blob",
        "path": "/MyWebSite/MyWebSite.sln",
        "url": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/items/MyWebSite/MyWebSite.sln?versionType=Commit"
      },
      "changeType": "add"
    },
    {
      "item": {
        "gitObjectType": "tree",
        "path": "/MyWebSite/packages",
        "isFolder": true,
        "url": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/items/MyWebSite/packages?versionType=Commit"
      },
      "changeType": "add"
    },
    {
      "item": {
        "gitObjectType": "tree",
        "path": "/MyWebSite/MyWebSite/App_Start",
        "isFolder": true,
        "url": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/items/MyWebSite/MyWebSite/App_Start?versionType=Commit"
      },
      "changeType": "add"
    },
    {
      "item": {
        "gitObjectType": "tree",
        "path": "/MyWebSite/MyWebSite/Areas",
        "isFolder": true,
        "url": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/items/MyWebSite/MyWebSite/Areas?versionType=Commit"
      },
      "changeType": "add"
    },
    {
      "item": {
        "gitObjectType": "tree",
        "path": "/MyWebSite/MyWebSite/Content",
        "isFolder": true,
        "url": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/items/MyWebSite/MyWebSite/Content?versionType=Commit"
      },
      "changeType": "add"
    },
    {
      "item": {
        "gitObjectType": "tree",
        "path": "/MyWebSite/MyWebSite/Controllers",
        "isFolder": true,
        "url": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/items/MyWebSite/MyWebSite/Controllers?versionType=Commit"
      },
      "changeType": "add"
    }
  ],
  "url": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/commits/be67f8871a4d2c75f13a51c1d3c30ac0d74d4ef4",
  "remoteUrl": "https://dev.azure.com/fabrikam/_git/Fabrikam-Fiber-Git/commit/be67f8871a4d2c75f13a51c1d3c30ac0d74d4ef4",
  "_links": {
    "self": {
      "href": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/commits/be67f8871a4d2c75f13a51c1d3c30ac0d74d4ef4"
    },
    "repository": {
      "href": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249"
    },
    "changes": {
      "href": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/commits/be67f8871a4d2c75f13a51c1d3c30ac0d74d4ef4/changes"
    },
    "web": {
      "href": "https://dev.azure.com/fabrikam/_git/Fabrikam-Fiber-Git/commit/be67f8871a4d2c75f13a51c1d3c30ac0d74d4ef4"
    },
    "tree": {
      "href": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/trees/7fa1a3523ffef51c525ea476bffff7d648b8cb3d"
    }
  }
}

Definitions

Name Description
ChangeCountDictionary
GitChange
GitCommit
GitPushRef
GitStatus

This class contains the metadata of a service/extension posting a status.

GitStatusContext

Status context that uniquely identifies the status.

GitStatusState

State of the status.

GitTemplate
GitUserDate

User info and date for Git operations.

IdentityRef
ItemContent
ItemContentType
ReferenceLinks

The class to represent a collection of REST reference links.

ResourceRef
VersionControlChangeType

The type of change that was made to the item.

ChangeCountDictionary

GitChange

Name Type Description
changeId

integer

ID of the change within the group of changes.

changeType

VersionControlChangeType

The type of change that was made to the item.

item

string

Current version.

newContent

ItemContent

Content of the item after the change.

newContentTemplate

GitTemplate

New Content template to be used when pushing new changes.

originalPath

string

Original path of item if different from current path.

sourceServerItem

string

Path of the item on the server.

url

string

URL to retrieve the item.

GitCommit

Name Type Description
_links

ReferenceLinks

A collection of related REST reference links.

author

GitUserDate

Author of the commit.

changeCounts

ChangeCountDictionary

Counts of the types of changes (edits, deletes, etc.) included with the commit.

changes

GitChange[]

An enumeration of the changes included with the commit.

comment

string

Comment or message of the commit.

commentTruncated

boolean

Indicates if the comment is truncated from the full Git commit comment message.

commitId

string

ID (SHA-1) of the commit.

committer

GitUserDate

Committer of the commit.

parents

string[]

An enumeration of the parent commit IDs for this commit.

push

GitPushRef

The push associated with this commit.

remoteUrl

string

Remote URL path to the commit.

statuses

GitStatus[]

A list of status metadata from services and extensions that may associate additional information to the commit.

treeId

string

url

string

REST URL for this resource.

workItems

ResourceRef[]

A list of workitems associated with this commit.

GitPushRef

Name Type Description
_links

ReferenceLinks

The class to represent a collection of REST reference links.

date

string

pushId

integer

pushedBy

IdentityRef

url

string

GitStatus

This class contains the metadata of a service/extension posting a status.

Name Type Description
_links

ReferenceLinks

Reference links.

context

GitStatusContext

Context of the status.

createdBy

IdentityRef

Identity that created the status.

creationDate

string

Creation date and time of the status.

description

string

Status description. Typically describes current state of the status.

id

integer

Status identifier.

state

GitStatusState

State of the status.

targetUrl

string

URL with status details.

updatedDate

string

Last update date and time of the status.

GitStatusContext

Status context that uniquely identifies the status.

Name Type Description
genre

string

Genre of the status. Typically name of the service/tool generating the status, can be empty.

name

string

Name identifier of the status, cannot be null or empty.

GitStatusState

State of the status.

Name Type Description
error

string

Status with an error.

failed

string

Status failed.

notApplicable

string

Status is not applicable to the target object.

notSet

string

Status state not set. Default state.

pending

string

Status pending.

succeeded

string

Status succeeded.

GitTemplate

Name Type Description
name

string

Name of the Template

type

string

Type of the Template

GitUserDate

User info and date for Git operations.

Name Type Description
date

string

Date of the Git operation.

email

string

Email address of the user performing the Git operation.

imageUrl

string

Url for the user's avatar.

name

string

Name of the user performing the Git operation.

IdentityRef

Name Type Description
_links

ReferenceLinks

This field contains zero or more interesting links about the graph subject. These links may be invoked to obtain additional relationships or more detailed information about this graph subject.

descriptor

string

The descriptor is the primary way to reference the graph subject while the system is running. This field will uniquely identify the same graph subject across both Accounts and Organizations.

directoryAlias

string

displayName

string

This is the non-unique display name of the graph subject. To change this field, you must alter its value in the source provider.

id

string

imageUrl

string

inactive

boolean

isAadIdentity

boolean

isContainer

boolean

isDeletedInOrigin

boolean

profileUrl

string

uniqueName

string

url

string

This url is the full route to the source resource of this graph subject.

ItemContent

Name Type Description
content

string

contentType

ItemContentType

ItemContentType

Name Type Description
base64Encoded

string

rawText

string

The class to represent a collection of REST reference links.

Name Type Description
links

object

The readonly view of the links. Because Reference links are readonly, we only want to expose them as read only.

ResourceRef

Name Type Description
id

string

url

string

VersionControlChangeType

The type of change that was made to the item.

Name Type Description
add

string

all

string

branch

string

delete

string

edit

string

encoding

string

lock

string

merge

string

none

string

property

string

rename

string

rollback

string

sourceRename

string

targetRename

string

undelete

string