GitHubでPull Requestを作成するとき、patchとdiffの2つの形式で変更内容を確認できます。
Pull RequestのURLの末尾に .patch または .diff を追加すると、Gitのプレーンテキストビューが表示されます。
このような表示を見たことがある方も多いのではないでしょうか?
ProTip! Add .patch or .diff to the end of URLs for Git’s plaintext views.

この2つの形式には以下のような違いがあります。
実際に自分が作成したPull Requestを例に、patchとdiffの違いを見てみましょう。
patch形式
例えば画像が含まれているとき、次のように表示されます。
From 7908e88a1715448e01213d1d846e3c3ec6bd12c4 Mon Sep 17 00:00:00 2001
From: lef237 <[email protected]>
Date: Mon, 5 Jan 2026 19:06:21 +0900
Subject: [PATCH 1/7] Add heart texture
---
art/heart.png | Bin 0 -> 62817 bytes
art/heart.png.import | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 34 insertions(+)
create mode 100644 art/heart.png
create mode 100644 art/heart.png.import
diff --git a/art/heart.png b/art/heart.png
new file mode 100644
index 0000000000000000000000000000000000000000..334225e28bb507b5ccb22f0168050f4cb0d5c29d
GIT binary patch
literal 62817
zcmbrkb9g4*wl5l|W81cEt2?%B+sPYsY?~e1cw=_#q+{E5a{F6rpS{<;=bpdLtfyv;
z8sj%G$E@e6IcipfqP!FWEG{ev2nd3Vw7Bx$>(}3N{TtNZzK7Z49|nYlh@1!rNPQgK
(省略)
r=3fQuQkxHE|MBJI|6PqCA4~>03z)$si32r2d=5D&WyvaWlc4_rU}pLT
literal 0
HcmV?d00001
diff --git a/art/heart.png.import b/art/heart.png.import
new file mode 100644
index 0000000..2bf152c
--- /dev/null
+++ b/art/heart.png.import
@@ -0,0 +1,34 @@
+[remap]
+
+importer="texture"
+type="CompressedTexture2D"
+uid="uid://c78koksxx6my5"
+path="res://.godot/imported/heart.png-d360d4cc98667652a308f99b846b988b.ctex"
+metadata={
+"vram_texture": false
+}
+
+[deps]
+
つまり、patch形式ではバイナリファイルの内容も含まれており、Gitのバイナリパッチ形式でエンコードされています。
diff形式
一方、diff形式では次のように表示されます。
diff --git a/art/heart.png b/art/heart.png
new file mode 100644
index 0000000..334225e
Binary files /dev/null and b/art/heart.png differ
diff --git a/art/heart.png.import b/art/heart.png.import
new file mode 100644
index 0000000..2bf152c
--- /dev/null
+++ b/art/heart.png.import
@@ -0,0 +1,34 @@
+[remap]
+
+importer="texture"
+type="CompressedTexture2D"
+uid="uid://c78koksxx6my5"
+path="res://.godot/imported/heart.png-d360d4cc98667652a308f99b846b988b.ctex"
+metadata={
+"vram_texture": false
+}
+
+[deps]
+
diff形式ではバイナリファイルの内容は含まれず、単に「Binary files differ」というメッセージが表示されます。
まとめ
まとめると、GitHubのPull Requestで提供されるpatch形式とdiff形式の主な違いは次のようになります。
- patch形式: バイナリファイルの内容も含まれ、Gitのバイナリパッチ形式でエンコードされている。
- diff形式: バイナリファイルの内容は含まれず、「Binary files differ」というメッセージが表示される。
バイナリファイルの内容が含まれると、パッチを適用する際に便利な場合がありますが、内容が大きくなるため注意が必要です。単純にコードの変更点のみを適用したい場合は、diff形式を使用するのがオススメです。1
Footnotes
-
言い換えると、git format-patch 相当の形式か、git diff 相当の形式かの違いとも言えます。 ↩