When you run
git diff to preview your changes before committing, you may see something like this:
diff --git a/README.md b/README.md index c39619d..230058e 100644 --- a/README.md +++ b/README.md @@ -1 +1,2 @@ This is a README file +README file is updated
@@ -1 +1,2 @@ mean?
This line describes a “window” with your changes.
It consists of two segments separated by a space:
These numbers are showing the coordinates of this window in the old and the new file.
@@ -1 +1,2 @@ line means that the window starts at line 1. There is no second number, that means that in the old file it is just one line.
The second window also starts at line 1, but it is two lines long.
Here is another example:
diff --git a/README.md b/README.md index 1f65bbe..21ea8f2 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ This is a README file. -It contains multiple lines. +We change the last line. +And add an extra line.
Here the first window starts at the first line and spans three lines. The second window starts at the first line and spans four lines.
There can be more than two windows at once.
For example when you merge two branches you can have three windows:
diff --cc README.md index f395431,1c91639..0000000 --- a/README.md +++ b/README.md @@@ -1,1 -1,1 +1,5 @@@ ++<<<<<<< HEAD +# Readme ++======= + # How to use the project ++>>>>>>> add-readme
One window is the old file, the second window is the new file, and the third window is the merge conflict.
Here Git explicitly states the amount of lines in each window:
- one line in the first window
- one line in the second window
- five lines in the third window
The third window being the merge conflict.
If you want to learn more about Git – check out the first chapter of my book “Command Line Git – Everything You Need to Know to Get Started”, after you subscribe to an email list – you will receive an email with a download link.