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

How to see which branch a commit was made on when grabbing commits and branches from the cloud api?

Mir Aman May 3, 2023{workspace}/{repo_slug}/commits


I am using the above endpoint to pull all commits from all projects and I want to be able to link commits to the branch it was made on. But I dont see any reference to the branch, under "parents" object, there is only reference to the parent commit. 

Does anyone know where I can find this relationship? 


1 answer

1 accepted

1 vote
Answer accepted
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 4, 2023

Hello @Mir Aman ,

Welcome to the Community!

While the List commits endpoint doesn't directly return the branches that the commit is part of, we do have a feature request opened to implement the ability to get the branches that contains a commit : 

Feel free to add your vote there and mark yourself as a watcher to receive first-hand updates on the implementation of that feature.

A workaround I can think of is to provide the branch name in the List commits endpoint so it will just return the commits for that specific branch, like in the below example :<workspace>/<repository>/commits/<branch name>

You could first get the List of branches and then for each branch returned, call the endpoint above to get all the commits contained in that particular branch.

Hope that helps!

Let me know in case you have any questions.

Thank you, @Mir Aman !

Patrik S

Mir Aman May 10, 2023

I just want to add incase anyone else needs this for future reference, the method suggested by Patrik works, but there is a lot of redundant data, as commits made on the parent branches are included in the child branch. This requires some cleanup after getting the response but otherwise is a good solution.

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events