0
0
Gitdevops~15 mins

git diff for working directory changes - Mini Project: Build & Apply

Choose your learning style9 modes available
Using git diff to See Working Directory Changes
📖 Scenario: You are working on a project using Git for version control. You want to check what changes you have made in your files before committing them.
🎯 Goal: Learn how to use the git diff command to see the changes in your working directory compared to the staging area.
📋 What You'll Learn
Have a Git repository initialized
Have at least one file tracked by Git
Make some changes to a tracked file
💡 Why This Matters
🌍 Real World
Checking changes before committing helps avoid mistakes and keeps your project history clean.
💼 Career
Understanding <code>git diff</code> is essential for developers and DevOps engineers to review code changes effectively.
Progress0 / 4 steps
1
Create a file and add initial content
Create a file called notes.txt with the exact content: Hello World.
Git
Need a hint?

You can use the echo command to write text to a file.

2
Add the file to Git tracking
Run the command git add notes.txt to start tracking the file in Git.
Git
Need a hint?

Use git add followed by the file name to stage the file.

3
Modify the file content
Change the content of notes.txt to exactly: Hello Git.
Git
Need a hint?

Use echo again to overwrite the file content.

4
Use git diff to see changes
Run the command git diff to display the changes made in notes.txt compared to the last staged version.
Git
Need a hint?

The output will show lines removed with a - and lines added with a +.