Understanding pull requests in Bitbucket Server

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 page aims to explain what happens during the lifecycle of a pull request in Bitbucket Server.

Solution

Diff view

See the Understanding Diff view in Bitbucket Server page for details.

Merge workflow

When a merge is triggered, the following two main actions are performed:

  • the merge itself

  • the removal of the source branch (if the "Delete source branch after merging" option is selected)

These operations can be found in the access log in the following format:

  • The merge request. When the merge is successful, the output code for this request is 200.

1 "POST /rest/api/latest/projects/<project_key>/repos/<repository_slug>/pull-requests/<pullrequest_id>/merge HTTP/1.0"
  • The branch deletion. This is triggered by the browser when the confirmation that the merge succeeded is received. When the deletion is successful, the output code for this request is 204.

1 "POST /rest/pull-request-source-branch-deletion/1.0/projects/<project_key>/repos/<repository_slug>/pull-requests/<pullrequest_id>"

When the debug log level is enabled, the Git commands are logged in the atlassian-bitbucket.log file:

1 2 3 4 5 6 7 git clone --no-checkout --shared -b <source_branch> /var/atlassian/application-data/bitbucket/shared/data/repositories/<repository_id> /var/atlassian/application-data/bitbucket/shared/data/bitbucket/tmp/git/<temporary_repository>.git   cd /var/atlassian/application-data/bitbucket/shared/data/bitbucket/tmp/git/<temporary_repository>.git git reset --quiet <target_branch_hash> -- git merge -m "Automatic merge" --no-ff --log <source_branch_hash>

Troubleshooting

In some cases, it may be needed to run some of all the commands above for testing (e.g. when the merge is slow or the merge does not produce the expected behavior).

This is possible by running them in the same order as Bitbucket Server does, please select a <temporary_repository> that does not already exist in Bitbucket Server.

1 2 3 4 5 6 7 git clone --no-checkout --shared -b <source_branch> /var/atlassian/application-data/bitbucket/shared/data/repositories/<repository_id> /var/atlassian/application-data/bitbucket/shared/data/bitbucket/tmp/git/<temporary_repository>.git   cd /var/atlassian/application-data/bitbucket/shared/data/bitbucket/tmp/git/<temporary_repository>.git git reset --quiet <target_branch_hash> -- git merge -m "Automatic merge" --no-ff --log <source_branch_hash>

Note that the Git repository itself will be left intact by these commands.

Updated on April 7, 2025

Still need help?

The Atlassian Community is here for you.