How to determine why there are fewer files in the diff view than the commit view - Bitbucket Server
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.
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.
- 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:
examplerepository with local branches for
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
[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