How to determine why there are fewer files in the diff view than the commit view - 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
Purpose
Within Bitbucket Server's GUI, a pull request's "Commits" view may list more files than what is seen in the "Diff" view. This is an analysis of how/why that may occur.
Cause
This issue can occur when changes are cherry picked on source and/or target branch, rebasing or changes being merged from other branches.
The pull request diff shows the actual changes that would be applied to the target branch as a result of merging the source branch into it. This could mean that the changes for example.file
already exist on master
and the pull request would not actually make any changes to the file. This can be a result of cherry-picking, rebasing, or the changes being merged from other branches.
Example Scenario
A file named b.rb is added committed and pushed to the master branch.
A feature branch named feature/diff_tester is created.
An exact copy of b.rb along with a new file, called a.rb is added, committed and pushed to the feature branch.
A pull request is created to merge the feature (source) branch back into the master (target) branch.
As is shown in the image below, the "Commits" view in the pull request shows both a.rb and b.rb:

The "Diff" view, however, only shows the a.rb file:

This is because when the feature branch is merged into the master branch, the only difference will be the a.rb file as both master and feature branch contain the exact same b.rb file.
We can simulate what Bitbucket Server is displaying by doing the following in a local clone of the example
repository with local branches for source-branch
and master
.
How to test from command line
In a working copy run the following and make note of the output – replace <source-branch> with the name of the source branch:
git checkout master
git merge <source-branch> --no-commit
git status
The output will be similar to this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
[nhansberry:~/dev/diff_test] git checkout master
Switched to branch 'master'
Your branch is up-to-date with 'origin/master'.
[nhansberry:~/dev/diff_test] git merge feature/diff_tester --no-commit
Automatic merge went well; stopped before committing as requested
[nhansberry:~/dev/diff_test] git status
On branch master
Your branch is up-to-date with 'origin/master'.
All conflicts fixed but you are still merging.
(use "git commit" to conclude merge)
Changes to be committed:
new file: a.rb
Was this helpful?