I create a branch called base
in which I create a file base.md
:
b
There are two empty lines then followed by b
character in the third line. If I edit the first line and add a
, the git diff
and the edited file shows:
diff --git a/base.md b/base.md
index f547db6..1e907b4 100644
--- a/base.md
+++ b/base.md
@@ -1,3 +1,3 @@
-
+a
b
\ No newline at end of file
(END)
a
b
I know git says it deletes the old first line and adds a new first line with an a
in there.
If I just add a new empty line in the end of the file:
diff --git a/base.md b/base.md
index f547db6..614705a 100644
--- a/base.md
+++ b/base.md
@@ -1,3 +1,3 @@
-b
\ No newline at end of file
+b
(END)
b
In this case, I know git says it deletes the old third line and adds a new third line with the b
(to be exact the b\n
) in there.
But if I edit the first line and add the new line together, the git diff
shows:
diff --git a/base.md b/base.md
index f547db6..a1a53b5 100644
--- a/base.md
+++ b/base.md
@@ -1,3 +1,3 @@
+a
-
-b
\ No newline at end of file
+b
(END)
It seems not just the simple addition of the above two operations. In my words, the git seems to say: First I'll create a new line with an a
for you(not just delete the old and then add the new), then I'll delete the old third line and add a new third line with the b\n
. And finally, cause there are two empty lines between the a
and b
, I'll delete one for you.
I couldn't find some information about the git diff
or it's related algorithms. Could some explain this to me? Thanks in advance.