# Diff

Being able to see the difference between two versions of a file is a critical function of version control. I made a small change to **hello.bat** and save as if I am working on a real project now.

<figure><img src="https://content.gitbook.com/content/cxcvbsS3tjLhOUUTuRd3/blobs/rY573ZGyDS5ySdFwJ4ah/image.png" alt=""><figcaption></figcaption></figure>

If I run the command&#x20;

```
git diff hello.bat
```

I get difference information on versions of the file. The minuses signify that something was removed from that version of the file, and the pluses signify that something is added to the file.

<figure><img src="https://content.gitbook.com/content/cxcvbsS3tjLhOUUTuRd3/blobs/AM0dPtaAiKPPwqqfH35e/image.png" alt=""><figcaption></figcaption></figure>

The <mark style="color:green;">green</mark> text with the + shows what was added.

The <mark style="color:red;">red</mark> text with the - shows what was subtracted.

GIT was always based on text files and will detect any change to any line. A small change to a line will be treated as if that line was deleted and then added as a new line.

If I type&#x20;

```
git status
```

I can see what the status of these changes is and it even tells me what to do.

<figure><img src="https://content.gitbook.com/content/cxcvbsS3tjLhOUUTuRd3/blobs/rUkh2vj1aA5ZswIZsrAl/image.png" alt=""><figcaption></figcaption></figure>

I can add the file and commit, or I can restore the previous version.

The **diff** command allows us to track back previous versions and see what changes have occurred to the current state. In the example below we can see unique _hash value_ associated with this update. Go research what a hash value is, we will cover it in more detail in the networking module.

<figure><img src="https://content.gitbook.com/content/cxcvbsS3tjLhOUUTuRd3/blobs/MkShEuv91HYssg5VADNf/Screenshot%202023-10-26%20120133.jpg" alt=""><figcaption></figcaption></figure>

I record the hash,&#x20;

To demonstrate how we can use this, I do an **add** and **commit** to store my second change.&#x20;

<figure><img src="https://content.gitbook.com/content/cxcvbsS3tjLhOUUTuRd3/blobs/7gkV0pa2AOH4fW4QGnMx/image.png" alt=""><figcaption></figcaption></figure>

I make another change, my third.

<figure><img src="https://content.gitbook.com/content/cxcvbsS3tjLhOUUTuRd3/blobs/ZozEQdFddigxhHk2uS7d/image.png" alt=""><figcaption></figcaption></figure>

You can see the first hash was 9240d5d.

<figure><img src="https://content.gitbook.com/content/cxcvbsS3tjLhOUUTuRd3/blobs/iTkroNNO7XkKKwuSDxcI/image.png" alt=""><figcaption></figcaption></figure>

I can now see the difference between the current version of the file, and the version whose unique id I quoted.
