init: git diff
In this video we'll learn how to use
git diff can be used for viewing current changes, but also historical changes.
Let's demonstrate this by making some changes to File 2.
When I run
git diff I'll see these changes.
Any additions are show as plus lines (in green) and any deletions are shown as minus lines (in red).
git log I can use the arrows keys to scroll through the changes and at any time I can type q to quit.
It's important to note that
git diff only displays changes to modified files.
That doesn't include changes to untracked or staged files.
Let's demonstrate this adding a timestamp to a new file.
If we run
git diff we'll see the same output as before.
If we add this file with
git add and run
git diff we'll also see the same output.
That's because the new file is now staged. We can verify this with
If I wanted to see the staged changes, I can use the
git diff --staged
Shows me the changes to be committed in new file we created.
You could also pass
git diff a file to limit its output to only the changes in that file.
git diff file-2.txt