Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How can i get the list of files based on commit id

visagan santhanam June 6, 2018

Hi,

using the Bitbucket Rest API is there a way to get the list of files based on commit id?

rest/api/1.0/projects/{projectname}/repos/{reponame}/commits/{commit id}

is not returning the list of files

 

2 comments

Caterina Curti
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 22, 2018

Hi @visagan santhanam,

If you use the following REST API endpoint:

rest/api/1.0/projects/{projectname}/repos/{reponame}/commits/{commit id}/changes

The reply will contain (among other information) the details of each files modified in the commit.

As an example, this is the related section from the entire json output:

path: {
components: [
"file1.txt"
],
parent: "",
name: "file1.txt",
extension: "txt",
toString: "file1.txt"
},

 

Here the link to our REST API documentation:

https://docs.atlassian.com/bitbucket-server/rest/latest/bitbucket-rest.html

 

Cheers,

Caterina - Atlassian

Like Gopika_Verma likes this
Saurabh Porwal August 17, 2022

hi @Caterina Curti  is there a way to do this with Bitbucket APIs 2.0?

Gopika_Verma February 20, 2020

I have a question related to above scenario. How can I get latest commit Id for a file from bitbucket rest api (not from UI)? We want to fetch the source commit Id for a file programmatically and use again to push updated content via bitbucket rest api

Basically i want rest api version of below command-

git log -n 1 --pretty=format:%H -- myfile

 

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events