Addon
Branch restrictions
Branching model
Commit statuses
Commits
Deployments
Downloads
Issue tracker
Pipelines
Projects
Pullrequests
Refs
Reports
Repositories
Snippets
Source
Ssh
Teams
Users
Webhooks
Workspaces
Other operations

Rate this page:

Source

Browse the source code in the repository and create new commits by uploading.

List commits that modified a file

GET /2.0/repositories/{workspace}/{repo_slug}/filehistory/{commit}/{path}

Returns a paginated list of commits that modified the specified file.

Commits are returned in reverse chronological order. This is roughly equivalent to the following commands:

1
2
3
$ git log --follow --date-order <sha> <path>

$ hg log --follow <path>

By default, Bitbucket will follow renames and the path name in the returned entries reflects that. This can be turned off using the ?renames=false query parameter.

Results are returned in descending chronological order by default, and like most endpoints you can filter and sort the response to only provide exactly the data you want.

For example, if you wanted to find commits made before 2011-05-18 against a file named README.rst, but you only wanted the path and date, your query would look like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
$ curl 'https://api.bitbucket.org/2.0/repositories/evzijst/dogslow/filehistory/master/README.rst'\
  '?fields=values.next,values.path,values.commit.date&q=commit.date<=2011-05-18'
{
  "values": [
    {
      "commit": {
        "date": "2011-05-17T07:32:09+00:00"
      },
      "path": "README.rst"
    },
    {
      "commit": {
        "date": "2011-05-16T06:33:28+00:00"
      },
      "path": "README.txt"
    },
    {
      "commit": {
        "date": "2011-05-16T06:15:39+00:00"
      },
      "path": "README.txt"
    }
  ]
}

In the response you can see that the file was renamed to README.rst by the commit made on 2011-05-16, and was previously named README.txt.

OAuth scopes required
repository

Request

Path parameters
commit Required

string

The commit's SHA1.

path Required

string

Path to the file.

repo_slug Required

string

This can either be the repository slug or the UUID of the repository, surrounded by curly-braces, for example: {repository UUID}.

workspace Required

string

This can either be the workspace ID (slug) or the workspace UUID surrounded by curly-braces, for example: {workspace UUID}.

Query parameters
renames

string

When true, Bitbucket will follow the history of the file across renames (this is the default behavior). This can be turned off by specifying false.

q

string

Query string to narrow down the response as per filtering and sorting.

sort

string

Name of a response property sort the result by as per filtering and sorting.

Example

1
2
3
4
curl --request GET \
  --url 'https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/filehistory/{commit}/{path}' \
  --header 'Authorization: Bearer <access_token>' \
  --header 'Accept: application/json'

Responses