How to get a list of repository forks in Bitbucket Server and Data Center
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.
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
The content on this page relates to platforms which are not supported. Consequently, Atlassian Support cannot guarantee providing any support for it. Please be aware that this material is provided for your information only and using it is done so at your own risk.
Summary
This article explains how to get a list of repositories that are forks together with the repositories from which they originate.
Environment
Bitbucket 8.11, but also applicable to other versions.
Solution
The following database query provides a list of repositories that are forks together with repositories from which they originate.
- First four columns are related to the repository forked from others.
- Last four columns are related to the original repository that is forked from.
-- list of repositories with forks
select
p.project_key project,
p."name" project_name,
p.project_type project_private,
r.slug repo,
--
po.project_key fork_of_project,
po."name" fork_of_project_name,
po.project_type fork_of_project_private,
ro.slug fork_of_repo
from sta_repo_origin sro
join repository r on r.id = sro.repository_id
join project p on p.id = r.project_id
join repository ro on ro.id = sro.origin_id
join project po on po.id = ro.project_id
order by
p.project_key,
r.slug;