Search code examples
gitgithubdiffgit-merge

Why Github does not automatically update the file comparison between two PRs?


I created three branches except main: b-release, b-A, b-B. And the b-A is created based on release-branch, while b-B is based on b-A.

main --- b-release
            |       
           b-A  ---  b-B

I also created three PRs:

  1. PR-release (compare to main): this pr is the changeLog consisting of PR-b-A and PR-b-B
  2. PR-b-A (compare to b-release): this pr is the changes in b-A
  3. PR-b-B (compare to b-release): this pr is the changes in b-B

The purpose is to merge PR-release into main after b-A and b-B merge into b-release.

However, after I merged the PR-b-A into PR-release, the files comparison in PR-b-B did not update. Even if I tried to change base to main and change back to b-release, it still was not changed.

Does anyone know how to update file changes on PR-b-B?


Solution

  • The diff displayed in a PR is the diff between :

    • the head of the branch (b-B in your case)
    • the fork point between that branch and the target branch (the fork point between b-B and b-release)

    If you look closely at how the branches behave : if you update the b-release branch, the fork point does not change (see diagram below).

    If you want to change what is displayed in the PR, you will have to change branch b-B.
    For example : run git rebase b-release after b-A has been merged. You will have to force push to origin after that.


    Taking your diagram :

    # before merging b-A :
    main --- b-release
                \       
                 * --- * --- b-A  --- * --- * --- b-B
    
    # after merging b-A :
    main ---   x     ---  b-release
                \              /
                 * --- * --- b-A  --- * --- * --- b-B
    
    # the fork point with 'b-release' is till commit 'x'
    
    # to update the fork point : change the history of branch b-B
    # after 'git rebase b-release' :
    main ---   x     ---  b-release
                \              /  \
                 * --- * --- b-A   * --- * --- b-B