How to find which repositories are actively being used

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

It's important for some teams to be able to report on which repositories in their system are actively being used for the purposes of archiving or removing old repositories that are no longer in use.

Environment

Bitbucket Server and Bitbucket Data Center.

Solution

While there's no kind of innate logging mechanism that accomplishes this request, it's possible to use the access logs in order to determine the number of requests made to a given repository.

  • ℹ️ For example, the following bash script takes a given access log list ($FILESTOSCAN) and then outputs any git-upload-pack operations found in the logs, and then groups them by the repository that the request was made against and outputs the 20 most-accessed repositories for the logs provided for HTTP and SSH independently.

1 2 3 4 5 6 7 8 9 FILESTOSCAN="atlassian-bitbucket-access*.log" echo "Number of Clones per Repository" echo "HTTP(s) clones:" grep -h "git-upload-pack" $FILESTOSCAN | grep ", clone" | grep -v "SSH" | awk -F '|' '{ print $6 }' | awk -F ' ' '{ print $2 }' | awk -F '/' '{ print $3"/"$4 }' | sed "s/'//" | sort | uniq -c | sort -n -r | awk '{printf "%'\''d - %s\n", $1, $2 }' > clone_count.rpt head -20 clone_count.rpt echo "SSH Clones:" grep -h "git-upload-pack" $FILESTOSCAN | grep ", clone" | grep "SSH" | awk -F '|' '{ print $6 }' | awk -F ' ' '{ print $4 }' | awk -F '/' '{ print $2"/"$3 }' | sed "s/'//" | sort | uniq -c | sort -n -r | awk '{printf "%'\''d - %s\n", $1, $2 }' > clone_count.rpt head -20 clone_count.rpt

The above script is provided on a best-effort basis, and Atlassian Support is unable to directly support this script or any customizations made to it to achieve your team's business needs.

Updated on April 2, 2025

Still need help?

The Atlassian Community is here for you.