Menu
Coddy logo textTech

Git Diff

Part of the Version Control section of Coddy's Terminal journey — lesson 15 of 58.

git diff shows you exactly what has changed in your working directory since the last commit. It is one of the most useful commands when you are mid-edit and want to remember what you have done.

git diff

Lines that were removed are prefixed with -; lines that were added are prefixed with +:

-print("hi")
+print("hello")

By default git diff compares the working directory to what was last committed. It does not show changes that are already staged. Run it before staging to review your edits one last time.

Unchanged context lines around your changes appear with a leading space, so you can see where the change happened in the file.

challenge icon

Challenge

Easy

The folder contains greet.py with the line print("hi"), already committed. Change the line to print("hello"), then run git diff to see your unstaged change.

Cheat sheet

git diff shows changes in the working directory since the last commit (unstaged changes only):

git diff

Removed lines are prefixed with -, added lines with +:

-print("hi")
+print("hello")

Try it yourself

Terminal
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Version Control