Git diff deep dive with examples

                    1 dev
2 initial
3 initial
4 master
┌───4444444─────┐
1 dev │ │ 1 init
2 initial ▼ ▼ 2 init
3 initial 3333333 2222222 3 init
4 initial │ │ 4 master
│ │
│ │
└─► 11111111◄───┘
1 initial
2 initial
3 initial
4 initial
$ git diff 11111 22222
diff --git a/file.txt b/file.txt
index cfd54b9..c9ed855 100644--- a/file.txt+++ b/file.txt@@ -1,4 +1,4 @@initialinitialinitial-initial+master
diff --git a/file.txt b/file.txtindex c9ed855..cfd54b9 100644--- a/file.txt+++ b/file.txt@@ -1,4 +1,4 @@initialinitialinitial-master+initial
$ git diff 333333 222222
diff --git a/file.txt b/file.txt
index 321263c..c9ed855 100644--- a/file.txt+++ b/file.txt@@ -1,4 +1,4 @@-devinitialinitialinitial+master
$ git diff 222222 3333333
diff --git a/file.txt b/file.txt
index c9ed855..321263c 100644--- a/file.txt+++ b/file.txt@@ -1,4 +1,4 @@+devinitialinitialinitial-master
$ git diff --merge-base 333333 22222
diff --git a/file.txt b/file.txt
index cfd54b9..c9ed855 100644--- a/file.txt+++ b/file.txt@@ -1,4 +1,4 @@initialinitialinitial-initial+master
$ git diff --merge-base 222222 3333333diff --git a/file.txt b/file.txtindex cfd54b9..321263c 100644--- a/file.txt+++ b/file.txt@@ -1,4 +1,4 @@-initial+devinitialinitialinitial
$ git show 44444444
diff --cc file.txt
index c9ed855,321263c..1ffe312--- a/file.txt+++ b/file.txt@@@ -1,4 -1,4 +1,4 @@@- initial+ devinitialinitial-initial+master
$ git diff 444444 222222 33333
diff --cc file.txt
index c9ed855,321263c..1ffe312--- a/file.txt+++ b/file.txt@@@ -1,4 -1,4 +1,4 @@@- initial+ devinitialinitial-initial+master

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store