Predict Diff Output
Predict Output Easy
Question
You change line 2 of a file from 'old' to 'new'. What does `git diff` show?
Code
# file.txt line 2 changed from "old" to "new"
git diff
Hint
Diff shows removed lines with - and added lines with +.
Explanation
git diff shows a unified diff: lines removed from the original are prefixed with -, and lines added are prefixed with +. So changing 'old' to 'new' shows -old and +new. The diff also includes file headers and line-number context.
Related Resources
Related Lessons
Related Cheatsheets
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.