LoginSignup
23
17

More than 5 years have passed since last update.

プルリクエストで表示される差分の仕組みを GitHub に問い合わせてみた

Last updated at Posted at 2018-05-29

背景

私の知識不足でもありますが、これまでプルリクエストで表示される差分は、ブランチ間のコミット、ソースコードの"差"である、という間違った認識を持っていました。

先日プルリクエストを作成したときに表示されたコミットとソースコードの差異が、from と to の、どちらにも存在していたことを不思議に思い、 GitHub に問い合わせをしてみました。

英語が苦手なので、回答に対する認識が合っているか不安です...。あと、もし失礼な表現とか送っていればすみません。

GitHub 問い合わせ

問い合わせフォームは下記URLです。
https://github.com/contact

下記 GitHub からの返事です。

Hi there,

Thanks for reaching out! This sounds like expected behavior, as we show the three-dot diff, or the difference between the most recent version of the head branch and the base branch at the time the head branch was created:

https://git-scm.com/docs/git-diff#git-diff-Comparingbranches

It sounds like you'd rather see a two-dot diff, which would show the changes between the most recent versions of each branch. If you'd like, you can merge the base branch back into the head branch. That would be more likely to show you what you're expecting to see.

Hope that helps clear up some of the confusion!

Regards,
*****
@********
GitHub Support


>Hi, GitHub Support.
>
>I wanted to ask difference of Pull-request.
>
>The other day GitHub page showed me differences of code+ and commit, when I created Pull-request (from to master-branch from feature-branch).
>But, master-branch had alredy the commits (same hash) and the codes (same number of lines) .
>Of cource, feature-a-branch also have it too. I thought it's not difference.
>
>Probably I guess it’s happened by construction(order of hash) of git-log.
>Is something wrong? Could you tell me what to do?
>
>I look forward to your response.
>
>Regards,
>Kenji Ichihashi=

プルリクエストの差分

GitHub のプルリクエストはブランチ間の差 ( $git diff develop..feature ) ではなく、
両ブランチの先祖(どちらからも参照できるコミット, 派生したところ?)と HEAD の差分( $git diff develop...feature ) で作られているそうです。

今回は、少し特殊なフローで Git を運用をしているリポジトリだったので、意図しない形の差分が表示されてしまいました。
ブランチ間の純粋な差分を見たい場合は、あらかじめ to のブランチを from のブランチへマージしてからプルリクエストを作成すればいいそうです。

※参考: git diffコマンドで比較する時のダブルドット(..)とトリプルドット(...)の違いとは?

さいごに

問い合わせに対して、GitHub からの返信は1営業日ほどで返ってきて、素晴らしい対応でした。

ただ、問い合わせをすべき内容、すべきでない内容、もしかしたらポリシー的なものがあるかもしれません。
もし、何かご存知のかたいらっしゃいましたら、ご教示いただけると幸いです。


過去に書いた Git関連の記事 :arrow_double_down:

Qiita-何も知らない人がGitとGitHubを独学で知る
Qiita-git checkout できないとき、私はこうしてます。
Qiita-ブランチ間の差分をコミット単位で知る・見る
Qiita-git 差分を見る

23
17
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
23
17