#author("2021-01-15T06:38:25+09:00","default:ryuichi","ryuichi")
#author("2021-01-15T11:32:17+09:00","default:ryuichi","ryuichi")
* ブランチ作成時と現在をスリードット(...)で比較する [#vd4f14df]
** スリードットで比較すると何が起きるのか? [#zba632fc]
git diff master...branch1
- masterブランチからbranch1ブランチを作成した時の状態と現在のbranch1ブランチの状態の比較を行う
** 前提 [#q8c1281d]
(1) git co master
(2) git co -b branch1
(3) vi 1.txt
(4) git add 1.txt; git commit -m 'Changed 1.txt'
(5) git co master
(6) vi 2.txt
(7) git add 2.txt; git commit -m 'Changed 2.txt'
- (1) masterブランチに入る
- (2) masterブランチからbranch1ブランチを作って入る
- (3) (4) 1.txtファイルを編集してAddしてCommitする
- (5) masterブランチに入る
- (6) (7) 2.txtファイルを編集してAddしてCommitする
** ブランチ作成時と現在をスリードット(...)で比較する [#w9b74fc9]
git diff master...branch1
diff --git a/1.txt b/1.txt
index 58c9bdf..2e6bfd4 100644
--- a/1.txt
+++ b/1.txt
@@ -1 +1 @@
-111
+111X
- 上のようにbranch1ブランチ作成時のmasterと現在のbranch1を比較するので、1.txtだけ表示される
- また、branch1ブランチ作成時のmasterの状態(=コミット)のことをマージベース(Merge Base)と呼ぶ
*** ツードット(..)で比較すると [#y063221f]
git diff master..branch1
diff --git a/1.txt b/1.txt
index 58c9bdf..2e6bfd4 100644
--- a/1.txt
+++ b/1.txt
@@ -1 +1 @@
-111
+111X
diff --git a/2.txt b/2.txt
index e7a15fa..c200906 100644
--- a/2.txt
+++ b/2.txt
@@ -1 +1 @@
-222Y
+222
- master1ブランチ作成後のコミットである2.txtも表示される
- すなわち、最新のmasterブランチと最新のbranch1ブランチを比較していることになる
- なお、'''git diff master..branch1'''は'''git diff master branch1'''としても同じでどちらでもよい
** (補足) git logのスリードットはgit diffとは意味が違うので注意する [#mf5cdbf4]
https://stackoverflow.com/questions/7251477/what-are-the-differences-between-double-dot-and-triple-dot-in-git-dif/7256391
** 参考 [#xa3ecc33]
https://stackoverflow.com/questions/7251477/what-are-the-differences-between-double-dot-and-triple-dot-in-git-dif/7256391