Delen via


Commits - Get Push Commits

Retrieve a list of commits associated with a particular push.

GET https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/commits?pushId={pushId}&api-version=7.1
GET https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/commits?pushId={pushId}&top={top}&skip={skip}&includeLinks={includeLinks}&api-version=7.1

URI Parameters

Name In Required Type Description
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 '7.1' to use this version of the api.

pushId
query True

integer (int32)

The id of the push.

includeLinks
query

boolean

Set to false to avoid including REST Url links for resources. Defaults to true.

skip
query

integer (int32)

The number of commits to skip.

top
query

integer (int32)

The maximum number of commits to return ("get the top x commits").

Responses

Name Type Description
200 OK

GitCommitRef[]

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

Sample request

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

Sample response

{
  "count": 1,
  "value": [
    {
      "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",
      "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"
        },
        "web": {
          "href": "https://dev.azure.com/fabrikam/_git/Fabrikam-Fiber-Git/commit/be67f8871a4d2c75f13a51c1d3c30ac0d74d4ef4"
        },
        "changes": {
          "href": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/commits/be67f8871a4d2c75f13a51c1d3c30ac0d74d4ef4/changes"
        }
      }
    }
  ]
}

Definitions

Name Description
ChangeCountDictionary
GitChange
GitCommitRef

Provides properties that describe a Git commit and associated metadata.

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 (int32)

ID of the change within the group of changes.

changeType

VersionControlChangeType

The type of change that was made to the item.

item

string (T)

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.

GitCommitRef

Provides properties that describe a Git commit and associated metadata.

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.

commitTooManyChanges

boolean

Indicates that commit contains too many changes to be displayed

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.

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 (date-time)

pushId

integer (int32)

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 (date-time)

Creation date and time of the status.

description

string

Status description. Typically describes current state of the status.

id

integer (int32)

Status identifier.

state

GitStatusState

State of the status.

targetUrl

string

URL with status details.

updatedDate

string (date-time)

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.

Value Description
error

Status with an error.

failed

Status failed.

notApplicable

Status is not applicable to the target object.

notSet

Status state not set. Default state.

pending

Status pending.

succeeded

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-time)

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

Deprecated - Can be retrieved by querying the Graph user referenced in the "self" entry of the IdentityRef "_links" dictionary

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

Deprecated - Available in the "avatar" entry of the IdentityRef "_links" dictionary

inactive

boolean

Deprecated - Can be retrieved by querying the Graph membership state referenced in the "membershipState" entry of the GraphUser "_links" dictionary

isAadIdentity

boolean

Deprecated - Can be inferred from the subject type of the descriptor (Descriptor.IsAadUserType/Descriptor.IsAadGroupType)

isContainer

boolean

Deprecated - Can be inferred from the subject type of the descriptor (Descriptor.IsGroupType)

isDeletedInOrigin

boolean

profileUrl

string

Deprecated - not in use in most preexisting implementations of ToIdentityRef

uniqueName

string

Deprecated - use Domain+PrincipalName instead

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

Value Description
base64Encoded
rawText

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.

Value Description
add
all
branch
delete
edit
encoding
lock
merge
none
property
rename
rollback
sourceRename
targetRename
undelete