Consider the following Git graph:
* 2ac0064 (HEAD -> master) Add lorem ipsum to Section 4
| * 9784cf5 (feature/B) Add " world" to Section 1
| * 9e32334 Add "hello" to Section 1
|/
* c2f6030 Add lorem ipsum to Section 3
| * fbc5b46 (feature/A) Add " world" to Section 1
| * 66674d3 Add "lo" to Section 1
| * 96b8620 Add "hel" to Section 1
|/
* 79c6f39 Add some section headers
* a41b867 Initial commit
As can bee seen, both feature/A
and feature/B
introduce the exact same changes (adding "hello world" to Section 1). However, they are separated by c2f6030
which makes unrelated changes to Section 3. How would I go about diffing only the changes introduced by feature/A
with the changes introduced by feature/B
?
git diff feature/A feature/B
produces the following diff, which is wrong, since I do not care about the unrelated changes introduced by c2f6030
in Section 3.
$ git diff feature/A feature/B
diff --git a/hello.txt b/hello.txt
index 789bbdc..5bc57c1 100644
--- a/hello.txt
+++ b/hello.txt
@@ -8,5 +8,7 @@ hello world
## Section 3
+Lorem ipsum dolor sit amet
+
## Section 4