CodeBlanks Logo Icon CodeBlanks

git diff

Learn to view changes with git diff.

View file changes

git diff displays changes in the working tree that have not been staged. After editing a file, you can use this command to inspect which lines have changed. It compares the current file contents with the last staged state.

git diff

This allows you to review your edits before creating a commit.

Read diff output

In git diff output, lines beginning with + represent added content, while lines beginning with - represent removed content. The section marked with @@ indicates which file lines are involved in the change.

-Hello
+Hello Git

In this example, the old line was removed and replaced with a new line.

Practice Display changes in the terminal

Write the git diff command to view unstaged changes in the working tree.

Starter code

terminal
# Sahnelenmemiş değişiklikleri göster
# Komutu buraya yaz

Sample solution

terminal
# Sahnelenmemiş değişiklikleri göster
git diff

Expected output

git diff komutu çalıştırılır

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 You edited a file but have not used git add yet. Which command should you run to see the changes?

  • git status --short
  • git commit
  • git diff Correct answer
  • git init

Explanation: <code>git diff</code> displays unstaged changes in the working tree.

2 Complete the diff command name

Question
git d____
Answer
git diff

Explanation: <code>git diff</code> displays unstaged changes in the working tree.

3 Diff output markers

Term Meaning
+ satırı Added content
- satırı Removed content
@@ Line location information
Working tree Current working files

All lessons in Beginner