Git: How to compare two different versions of a file

If you’re using Git and need to compare two recent versions of the same file, I can confirm that this git diff command works:

git diff HEAD^ HEAD nodeBlog.scala.html

That command compares the second-most recent version of the file (given by HEAD^) to the most recent version of the file (HEAD). In this example I want to see the detailed differences of these versions of the file named nodeBlog.scala.html. In my case, the result of this command is shown in the image.

As shown on this SO page, there are other ways to issue this Git command, and similar commands.

In summary, if you need to compare two versions of a file when using Git, I hope this example is helpful.

Photo D8
Git: How to compare two different versions of a file