How to list the last modification time for all branches in all repositories in Bitbucket Data Center using a script

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Summary

This knowledge base article covers how we can list the last modification date of all branches within all repositories within Bitbucket Data Center.

Solution

Prerequisites

You will need to have filesystem access to the $BITBUCKET_HOME directory

Bitbucket Data Center will store raw Git repositories under $BITBUCKET_HOME/shared/data/repositories/\#. We can obtain the date and branch name from Git using the following command:

1 git for-each-ref --sort=-committerdate:iso8601 --format='%(committerdate:iso8601)%09%(refname)' refs/heads

To list this for all repositories we can loop using the following bash script:

1 2 3 4 5 6 7 8 9 10 #!/bin/bash cd $BITBUCKET_HOME/shared/data/repositories for rep in [0-9]* do cd $rep grep -E 'project|repository' repository-config git for-each-ref --sort=-committerdate:iso8601 --format='%(committerdate:iso8601)%09%(refname)' refs/heads cd .. done

This will produce output similar to the following:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 project = TST repository = testing 2021-07-28 09:29:37 +1000 refs/heads/Development 2020-10-01 04:31:31 +0000 refs/heads/master 2020-10-01 04:30:48 +0000 refs/heads/Staging project = RW repository = realwork 2021-01-20 20:36:13 +1100 refs/heads/Development 2018-10-24 09:19:23 +1100 refs/heads/master 2018-10-24 09:18:49 +1100 refs/heads/Staging project = CP repository = wombat 2019-02-28 13:10:06 +1100 refs/heads/master ...

Updated on March 14, 2025

Still need help?

The Atlassian Community is here for you.