How to find all added or removed commits from Pull Request Updates

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

After a pull request is created, any updates to the branch will cause the pull request to be updated. If the commits listed are more than 5 the UI will show a number of commits added or removed but not list them.  This should show you all of the activity in that pull request. Here is the process to find all of the commits id's of the commits not listed: 

Solution

Start with the ID of the pull request from the URL.  When viewing URL of the pull request, the pull request id is the number near the end of the URL.  In this example, "pull-requests/96/overview" is the end of the pull request URL, where '86' will be the ID used in the following query:

1 2 3 SELECT activity_id FROM sta_pr_activity WHERE pr_id = 96;

We can then create new queries on sta_pr_rescope_activity based on the specific activity ID returned above. If you include the above query in your where clause, you can create something like:

1 2 3 4 5 6 7 SELECT * FROM sta_pr_rescope_activity WHERE activity_id IN ( SELECT activity_id FROM sta_pr_activity WHERE pr_id = <activity_id> );

Example output:

1 2 3 4 activity_id | from_hash | to_hash | prev_from_hash | prev_to_hash | commits_added | commits_removed -------------+------------------------------------------+------------------------------------------+------------------------------------------+------------------------------------------+---------------+----------------- 1855 | 5daa180799c9a0ca85e915cb918e8a869c22bba0 | 6158cc2c288e89b8ea1345c8f46bf30d84fb4780 | c36310e6851897dc067599121125d737fab6cd21 | 6158cc2c288e89b8ea1345c8f46bf30d84fb4780 | 1 | 0 1857 | fa6952ea38d3362da80fef0d8c7d6bbaf4a38835 | 6158cc2c288e89b8ea1345c8f46bf30d84fb4780 | 5daa180799c9a0ca85e915cb918e8a869c22bba0 | 6158cc2c288e89b8ea1345c8f46bf30d84fb4780 | 1 | 0

This shows you all of the activity in the Pull Request.  The number of commits_removed or commits_added to the pull request will help you limit the number of possible hashes used for the next step.  To get the list of commit id's run these two commands from any of the lines returned in the SQL above.  The column names should be replaced with the actual hash below:

1 2 git rev-list --ancestry-path <to_hash>..<from_hash> git rev-list --ancestry-path <prev_to_hash>..<prev_from_hash>

Updated on February 14, 2025

Still need help?

The Atlassian Community is here for you.