Bitbucket Server/Data Center shows diff between branches even after they are merged (using squash commit)

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問


プラットフォームについて: Server および Data Center のみ。この記事は、Server および Data Center プラットフォームのアトラシアン製品にのみ適用されます。

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.

*Fisheye および Crucible は除く

要約

When a feature branch is merged to the target branch using squash commit, comparing the two branches post the squash commit merge still shows the diffs.

環境

All versions of Bitbucket Server/DC.

診断

  • Create a branch say feature/newfeature1 from master and add some changes to a file test.txt.





























  • After the merge again compare the branch feature/newfeature1 with master. It can be noticed that the same diff is still shown even after the contents of the feature branch are now part of master.


原因

This is an expected behaviour when using squash merge strategy. Squash commit combines all of the feature branch's commits into one new non-merge commit on the target branch. It is important to note that unlike the normal merge commit squash commits are non merge commits (have single parent) and hence do not link the two branch histories together.

Below is a visual representation of the difference between squash commit and merge commit.

Merging with squash commit (Note the common ancestor between the branches is not updated hence the the diffs will still be shown from the old common ancestor)

Merging with merge commit (Note the common ancestor is updated hence the the diffs will be shown from the new common ancestor)

ソリューション

Merge the feature branch into master again using merge commit. This will update the common ancestor between the branches which in turn will update the diffs.


When using squash merging, it is a good practise to delete the source branch after the merge. This will avoid unintended problems later as the target branch doesn't have a merge commit linking it into the source branch and hence will show problematic diffs when compared.





最終更新日 2023 年 4 月 12 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.