0
0
Gitdevops~15 mins

Untracked vs tracked files in Git - Hands-On Comparison

Choose your learning style9 modes available
Understanding Untracked vs Tracked Files in Git
📖 Scenario: You are working on a new project using Git for version control. You want to understand which files Git is tracking and which files are new and untracked.
🎯 Goal: Learn how to identify untracked and tracked files in a Git repository using basic Git commands.
📋 What You'll Learn
Create a new Git repository
Create a new file and check its status
Add the file to Git tracking
Check the status again to see the difference
💡 Why This Matters
🌍 Real World
When working on software projects, developers need to know which files are new and not yet tracked by Git to avoid losing work or committing unwanted files.
💼 Career
Understanding tracked vs untracked files is essential for any developer or DevOps engineer to manage code changes safely and collaborate effectively.
Progress0 / 4 steps
1
Initialize a Git repository and create a new file
Run git init to create a new Git repository. Then create a new file called example.txt with the content Hello Git.
Git
Need a hint?

Use git init to start the repo. Use echo to create the file with content.

2
Check the status of files in the repository
Run git status to see the current state of files. Look for the file example.txt and note if it is untracked.
Git
Need a hint?

Use git status to see untracked files listed under 'Untracked files'.

3
Add the file to Git tracking
Run git add example.txt to start tracking the file. This moves it from untracked to staged.
Git
Need a hint?

Use git add example.txt to stage the file for commit.

4
Check the status again to see tracked files
Run git status again to see that example.txt is now staged and tracked.
Git
Need a hint?

After adding, git status shows the file under 'Changes to be committed'.