0
0
Gitdevops~30 mins

Working directory state in Git - Mini Project: Build & Apply

Choose your learning style9 modes available
Understanding Git Working Directory State
📖 Scenario: You are working on a small project using Git to manage your files. You want to understand how Git tracks changes in your working directory before you commit them.
🎯 Goal: Learn how to check the state of your working directory using Git commands to see which files are modified, staged, or untracked.
📋 What You'll Learn
Create a new file in the working directory
Modify the file
Use Git commands to check the working directory state
Understand the output of git status
💡 Why This Matters
🌍 Real World
Developers use Git to track changes in their project files. Understanding the working directory state helps avoid mistakes before committing code.
💼 Career
Knowing how to check and interpret the working directory state is essential for software developers, DevOps engineers, and anyone collaborating on code.
Progress0 / 4 steps
1
Create a new file in the working directory
Create a new file called example.txt with the exact content Hello, Git! in your working directory.
Git
Need a hint?

You can use the echo command to create a file with content.

2
Initialize Git repository, stage, and commit the file
Initialize a Git repository in the current directory using git init, add the file example.txt to the staging area using git add example.txt, and commit it using git commit -m "Initial commit".
Git
Need a hint?

Use git init to start a new repository, git add to stage files, and git commit -m "Initial commit" to commit them.

3
Modify the file and check working directory state
Modify the file example.txt by adding the line Welcome to Git learning. Then use git status to check the state of your working directory.
Git
Need a hint?

Use >> to append text to a file. Then run git status to see changes.

4
Display the output of git status
Run git status and display the output showing that example.txt has been modified but not staged.
Git
Need a hint?

The output of git status should list example.txt as modified but not staged.