How to find the latest commit made on a branch?

I'm trying to extract the last commit made to a certain branch.


I have something like this here:{abcd}/repos/{abcde-fghi}/branches/info/{CommitID} but what I do not get in this request is the time the last commit was made to this branch.

Is there a way to achieve that?

2 answers

0 vote

Hi Vivek,

You can use the following to get the last commit:

git log -1 

To just get the date you can do the following:

git log -1 --format=%cd 



If you need to get latest commit on a branch through the REST api, try the "/commits" call with the "until" parameter set to the branch you are interested in, and limit=1 to get the single tip commit from the branch.



The "authorTimestamp" in the result will tell you when the commit was first created.

If you're on Bitbucket 5.0 or newer, then a "committerTimestamp" should be present as well.   If an original commit was rebased or cherry-picked or squashed, the "committerTimestamp" will tell you when those operations happened.

The actual "push" time for when the commit arrived at the server is much harder to determine.

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Piotr Plewa
Published Dec 27, 2017 in Bitbucket

Recipe: Deploying AWS Lambda functions with Bitbucket Pipelines

Bitbucket Pipelines helps me manage and automate a number of serverless deployments to AWS Lambda and this is how I do it. I'm building Node.js Lambda functions using node-lambda&nbsp...

1,747 views 1 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you