Git File Status & Workflow: Understanding Untracked, Staged, and Modified Files with Real Terminal Examples

Complete beginner's guide to Git file status system. Learn about untracked, tracked, modified, and staged files, understand the staging area, make your first commits, and explore git log with detailed terminal output explanations.

26 min read

Now that you have Git installed and your first repository created, it's time to understand how Git tracks files and manages changes. This tutorial follows our real terminal session, explaining every file status, staging operation, and commit with complete detail for absolute beginners.

💡

🎯 What You'll Learn: In this hands-on tutorial, you'll discover:

  • The complete Git file status system (untracked, tracked, modified, staged)
  • What the staging area is and why it exists
  • How to add files to Git tracking with detailed command explanations
  • Making your first commits with meaningful messages
  • Understanding Git log output and commit history
  • Real-world workflow patterns for daily development
  • Every Git status message explained line by line Prerequisites: Git installed and first repository created (Part 3)

📊 Understanding Git File Status System

The Four File States in Git

Before we dive into our terminal session, let's understand the four possible states any file can be in within a Git repository:

File StatusDescriptionGit's KnowledgeNext Action
UntrackedFile exists but Git doesn't know about itNot watching this fileUse git add to start tracking
Tracked (Unmodified)File is tracked and hasn't changedKnows this file, no changes detectedNothing - file is up to date
ModifiedFile is tracked and has been changedKnows file changed since last commitUse git add to stage changes
StagedChanges are ready to be committedChanges prepared for next snapshotUse git commit to save snapshot

Visual File Status Flow

File Lifecycle in Git:

New File → [git add] → Staged → [git commit] → Tracked (Unmodified)
                         ↑                           ↓
                    [git add]                   [edit file]
                         ↑                           ↓
                      Modified ← ← ← ← ← ← ← ← ← ← ← ← ← ←

Key Insight: Files move between these states as you work. Understanding this flow is crucial for effective Git usage.

📁 Creating Your First Files

Let's start by creating some files in our repository and watch how Git reacts:

Creating the First File

[centos9@vbox myproject 16:45:48]$ touch first.txt
[centos9@vbox myproject 16:46:37]$ nano first.txt
[centos9@vbox myproject 16:46:45]$ cat first.txt
hello

Command Breakdown:

  • touch first.txt - Creates an empty file named "first.txt"
  • nano first.txt - Opens the file in the nano text editor
  • cat first.txt - Displays the contents of the file

What happened: We created a file with the content "hello". Git doesn't know about this file yet.

Checking Git Status After File Creation

[centos9@vbox myproject 16:46:58]$ git status
On branch master

No commits yet

Untracked files:
  (use "git add <file>..." to include in what will be committed)
	first.txt

nothing added to commit but untracked files present (use "git add" to track)

Understanding the New Git Status Output

Status LineMeaningWhat Git Is Telling You
"Untracked files:"Git found files it doesn't track"I see new files but I'm not watching them"
"use "git add <file>...""Instruction to start tracking"If you want me to track these, use git add"
"first.txt"Specific untracked file"This is the file I'm not tracking"
"nothing added to commit"No changes staged for commit"No files ready to be saved in a snapshot"

Adding a Second File

Let's create another file to see how Git handles multiple untracked files:

[centos9@vbox myproject 16:47:01]$ touch second
[centos9@vbox myproject 16:47:45]$ git status
On branch master

No commits yet

Untracked files:
  (use "git add <file>..." to include in what will be committed)
	first.txt
	second

nothing added to commit but untracked files present (use "git add" to track)

Key Observation: Git now shows both untracked files. Git detects all files in your working directory and reports their status.

📋 Understanding the Staging Area

What is the Staging Area?

The Staging Area (also called "Index") is like a preparation area for your next commit. Think of it as:

Photo Album Analogy:

  • Working Directory = Photos scattered on your desk
  • Staging Area = Photos you've selected and arranged for the next album page
  • Repository = The completed album pages (commits)

Why does the staging area exist?

  • Selective Commits: Choose exactly which changes to include
  • Review Changes: Double-check what you're about to commit
  • Organize Work: Group related changes together
  • Flexibility: Stage some files, continue working on others

Adding Files to Staging Area

Let's add our files to the staging area:

[centos9@vbox myproject 16:47:48]$ git add .
[centos9@vbox myproject 16:48:32]$ # or "git add first.txt second"

Command Options Explained:

  • git add . - Add all files in current directory and subdirectories
  • git add first.txt second - Add specific files by name
  • git add *.txt - Add all files matching a pattern (all .txt files)
  • git add --all or git add -A - Add all files in the repository

Checking Status After Staging

[centos9@vbox myproject 16:49:15]$ git status
On branch master

No commits yet

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)
	new file:   first.txt
	new file:   second

Understanding Staged File Status

Status ChangeBefore git addAfter git add
Section Header"Untracked files:""Changes to be committed:"
File StatusListed as untracked"new file:" prefix shows they're staged
Next Action"use git add" to track"git rm --cached" to unstage
Git's Understanding"I don't know these files""These files are ready for the next commit"

💾 Making Your First Commit

What is a Commit?

A commit is like taking a snapshot of your project at a specific moment. Each commit includes:

Every Commit Contains:

  • 📸 Snapshot: Complete state of all staged files
  • 👤 Author: Who made this commit (from git config)
  • 📅 Timestamp: Exactly when the commit was made
  • 📝 Message: Description of what changed and why
  • 🔗 Parent: Link to previous commit (building the timeline)
  • 🔢 Hash: Unique identifier for this exact commit

Creating Your First Commit

[centos9@vbox myproject 16:49:19]$ git commit -m "added files first.txt and second"
[master (root-commit) c9c6bf3] added files first.txt and second
 2 files changed, 1 insertion(+)
 create mode 100644 first.txt
 create mode 100644 second

Breaking Down the Commit Command

Command PartPurposeExplanation
git commitCreate a commit from staged changesTakes a snapshot of all staged files
-mAdd message directly on command lineAvoids opening text editor for message
"added files..."Commit message describing changesShould be clear and descriptive

Understanding Git's Commit Response

Let's decode every part of Git's response:

Output PartValueMeaning
[mastermasterCommit was made on the master branch
(root-commit)root-commitThis is the very first commit (no parent)
c9c6bf3]c9c6bf3Short hash (first 7 chars of unique commit ID)
2 files changed2Number of files affected by this commit
1 insertion(+)1Number of lines added (the "hello" line)
create mode 100644100644File permissions (regular file, readable/writable)

Checking Status After Commit

[centos9@vbox myproject 16:50:12]$ git status
On branch master
nothing to commit, working tree clean

What This Means:

  • "nothing to commit": All changes have been saved in the commit
  • "working tree clean": No modified files, everything matches the last commit
  • No "No commits yet": We now have commit history!

📜 Exploring Git Log

Viewing Commit History

[centos9@vbox myproject 16:50:17]$ git log
commit c9c6bf38440b6bd55fd5d32f8dc37a4b079ce012 (HEAD -> master)
Author: Owais Abbasi <owais.abbasi9@gmail.com>
Date:   Mon Sep 22 16:50:12 2025 +0500

    added files first.txt and second

Understanding Git Log Output

Log ElementValuePurpose
commitc9c6bf38440b6bd55fd5d32f8dc37a4b079ce012Full unique hash for this commit
(HEAD -> master)Current positionYou are here, on master branch
AuthorOwais Abbasi <owais.abbasi9@gmail.com>Who made this commit (from git config)
DateMon Sep 22 16:50:12 2025 +0500Exact timestamp with timezone
Messageadded files first.txt and secondDescription of what this commit does

🔄 Working with Modified Files

Now let's see what happens when we modify existing files:

Modifying an Existing File

[centos9@vbox myproject 16:50:42]$ nano first.txt
[centos9@vbox myproject 16:51:27]$ cat first.txt
hello

working

What we did: Added a new line "working" to first.txt file.

Git Status After File Modification

[centos9@vbox myproject 16:51:29]$ git status
On branch master
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   first.txt

no changes added to commit (use "git add" and/or "git commit -a")

Understanding Modified File Status

Status ElementMeaningWhat Git Knows
"Changes not staged"File has been modified but not added to staging"I see changes but they're not ready to commit"
"modified: first.txt"Specific file that has changes"This file is different from last commit"
"git restore"Option to undo changes"You can undo these changes if you want"
"no changes added to commit"Nothing in staging area"Nothing ready for next commit yet"

Multiple Modified Files

Let's modify the second file too:

[centos9@vbox myproject 16:51:35]$ nano second
[centos9@vbox myproject 16:52:35]$ cat second
working

[centos9@vbox myproject 16:52:36]$ git status
On branch master
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   first.txt
	modified:   second

no changes added to commit (use "git add" and/or "git commit -a")

Key Observation: Git tracks all modified files and lists them separately. Each file moves through the status system independently.

🎯 Selective Staging and Committing

Staging Only One File

Let's demonstrate selective staging by adding only one file:

[centos9@vbox myproject 16:52:38]$ git add first.txt
[centos9@vbox myproject 16:52:53]$ git status
On branch master
Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
	modified:   first.txt

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   second

Understanding Mixed Status

This status output shows a crucial Git concept: files can be in different states simultaneously:

FileStatusWhat This MeansNext Action
first.txtStaged (ready to commit)Changes will be included in next commitCan commit now or stage more files
secondModified (not staged)Changes exist but won't be in next commitUse git add to stage, or leave for later

Committing Staged Changes

[centos9@vbox myproject 16:52:57]$ git commit -m "update first.txt"
[master 4d0a85e] update first.txt
 1 file changed, 2 insertions(+)

Important: Only the staged file (first.txt) was committed. The modified second file remains in the working directory.

Status After Partial Commit

[centos9@vbox myproject 16:53:49]$ git status
On branch master
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   second

no changes added to commit (use "git add" and/or "git commit -a")

Key Insight: After committing first.txt, it's no longer shown as modified. Only the unstaged file (second) appears in the status.

📜 Viewing Complete Git History

Let's look at our commit history with multiple commits:

[centos9@vbox myproject 16:53:53]$ git log
commit 4d0a85ecd7b063d5c20089e754577481b07772f4 (HEAD -> master)
Author: Owais Abbasi <owais.abbasi9@gmail.com>
Date:   Mon Sep 22 16:53:49 2025 +0500

    update first.txt

commit c9c6bf38440b6bd55fd5d32f8dc37a4b079ce012
Author: Owais Abbasi <owais.abbasi9@gmail.com>
Date:   Mon Sep 22 16:50:12 2025 +0500

    added files first.txt and second

Understanding Git Log Timeline

Commit OrderCommit HashWhat HappenedStatus
Latest (top)4d0a85e...Updated first.txt file(HEAD -> master) Current position
Previousc9c6bf3...Initial commit with both filesParent of current commit

Key Points:

  • Newest commits appear first (reverse chronological order)
  • HEAD -> master shows where you currently are
  • Each commit has unique hash for precise identification
  • Complete timeline of your project's evolution

🎯 Git Workflow Summary

The Complete Git Workflow

Daily Git Workflow:

  1. Create/Edit Files → Files are untracked or modified
  2. git status → See what files have changed
  3. git add <files> → Move files to staging area
  4. git status → Verify what's staged for commit
  5. git commit -m "message" → Create snapshot with meaningful message
  6. git log → Review your commit history
  7. Repeat → Continue developing with confidence

Best Practices for Commit Messages

QualityExampleWhy
Good"Add user authentication feature"Clear, describes what was added
Good"Fix login bug for mobile users"Explains what was fixed and for whom
Poor"stuff"Too vague, no useful information
Poor"changed file"Doesn't explain what changed or why

📋 Git File Status & Workflow Quick Reference Cheat Sheet

🚀 Essential Git Commands

# Check repository status
git status

# Add files to staging area
git add filename.txt          # Add specific file
git add .                     # Add all files in current directory
git add *.txt                 # Add all .txt files

# Commit changes
git commit -m "Your message"  # Commit with message
git commit                    # Open editor for commit message

# View commit history
git log                       # Full commit history
git log --oneline            # Compact one-line format

📊 File Status System Reference

StatusWhat It MeansGit Status ShowsNext Action
UntrackedNew file Git doesn't know about"Untracked files: filename.txt"git add filename.txt
ModifiedTracked file has changes"modified: filename.txt"git add filename.txt
StagedChanges ready to commit"new file: filename.txt" or "modified: filename.txt"git commit -m "message"
CommittedChanges saved in repository"working tree clean"Continue working

🔄 Complete Workflow Patterns

Pattern 1: Adding New Files

# 1. Create new file
touch newfile.txt
echo "content" > newfile.txt

# 2. Check status (will show untracked)
git status

# 3. Add to staging area
git add newfile.txt

# 4. Check status (will show staged)
git status

# 5. Commit
git commit -m "Add new file with initial content"

# 6. Verify (should show clean working tree)
git status

Pattern 2: Modifying Existing Files

# 1. Edit existing file
echo "new content" >> existing.txt

# 2. Check status (will show modified)
git status

# 3. Add changes to staging
git add existing.txt

# 4. Commit changes
git commit -m "Update existing file with new content"

Pattern 3: Working with Multiple Files

# 1. Modify multiple files
echo "content1" > file1.txt
echo "content2" > file2.txt
echo "content3" > file3.txt

# 2. Check what's changed
git status

# 3. Stage specific files
git add file1.txt file2.txt    # Add specific files
# OR
git add .                      # Add all files

# 4. Commit with descriptive message
git commit -m "Add three new configuration files"

🎯 Git Status Output Decoder

Git Status MessageWhat It MeansWhat To Do
"On branch master"Shows current branch nameInformation only
"No commits yet"Repository has no commit historyMake your first commit
"Changes to be committed:"Files in staging areaReady to commit
"Changes not staged:"Modified files not yet stagedUse git add to stage
"Untracked files:"New files Git doesn't trackUse git add to start tracking
"working tree clean"No changes detectedNothing to do

💡 Command Variations & Tips

CommandWhat It DoesWhen To Use
git add .Add all files in current directoryWhen you want to stage everything
git add *.txtAdd all .txt filesWhen staging specific file types
git add file1 file2Add multiple specific filesFor selective staging
git log --onelineCompact commit historyQuick overview of commits
git log -n 5Show last 5 commitsLimit log output
git status -sShort status formatQuick status check

📝 Commit Message Best Practices

Good Commit Message Format

# Pattern: [Type]: [Brief description]
git commit -m "Add: user authentication system"
git commit -m "Fix: login validation bug"
git commit -m "Update: README with installation steps"
git commit -m "Remove: deprecated configuration file"

Message Type Examples

TypeUse WhenExample
AddCreating new files or features"Add contact form validation"
FixCorrecting bugs or issues"Fix mobile navigation menu"
UpdateModifying existing functionality"Update API endpoint responses"
RemoveDeleting files or features"Remove unused CSS files"
RefactorCode cleanup without changing functionality"Refactor user service methods"

🚨 Common Scenarios & Solutions

Scenario 1: Accidentally Staged Wrong File

# Problem: Added wrong file to staging
git add wrong-file.txt

# Solution: Remove from staging (keeps file changes)
git reset wrong-file.txt

# Then add the correct file
git add correct-file.txt

Scenario 2: Want to See What Changed

# See what files changed (not staged yet)
git diff

# See what files are staged for commit
git diff --staged

# See specific file changes
git diff filename.txt

Scenario 3: Check Specific Commit Details

# Show detailed info about latest commit
git show

# Show specific commit (replace with actual hash)
git show 4d0a85e

# Show files changed in commit
git show --name-only 4d0a85e

🎯 Daily Workflow Checklist

Before Starting Work:

  • [ ] git status - Check current state
  • [ ] git log --oneline -5 - Review recent commits

During Development:

  • [ ] Create/edit files as needed
  • [ ] git status - See what changed
  • [ ] git add <files> - Stage your changes
  • [ ] git status - Verify staging area
  • [ ] git commit -m "Clear message" - Save snapshot

After Commits:

  • [ ] git log --oneline - Verify commit was created
  • [ ] git status - Confirm clean working tree

🔧 Troubleshooting Quick Fixes

ProblemSymptomsSolution
Nothing to commit"working tree clean"Make some changes first, then git add
Files not included in commitStill showing as modifiedUse git add before git commit
Commit message editor opensText editor instead of command lineAlways use git commit -m "message"
Too many files to add individuallyMany untracked filesUse git add . to add all

🎯 Key Takeaways

✅ Essential Concepts Mastered

  1. File Status System: Understood untracked, modified, staged, and committed states

  2. Staging Area: Learned why it exists and how to use it for selective commits

  3. Git Commands: Mastered git add, git commit, git status, and git log

  4. Workflow Pattern: Create → Add → Commit → Repeat with meaningful messages

  5. Selective Commits: Can stage some files while leaving others for later

  6. History Tracking: Git log shows complete timeline with author, date, and messages

  7. Status Interpretation: Can read and understand Git's status messages

🎉 Congratulations! You now understand the fundamental Git workflow and can:

  • ✅ Track files and understand their status in Git
  • ✅ Use the staging area to prepare commits selectively
  • ✅ Create meaningful commits with descriptive messages
  • ✅ View and interpret your project's commit history
  • ✅ Work with modified files and understand Git's feedback
  • ✅ Follow a professional Git workflow for daily development

You have the foundation for effective version control in any project!

💬 Discussion

How was your experience with the Git workflow?

  • Which part of the file status system was most confusing initially?
  • Did the staging area concept make sense with the photo album analogy?
  • Have you tried the selective staging workflow in your own projects?
  • What challenges do you face with writing good commit messages?
  • Do you understand why Git shows so much information in its status output?
Owais

Written by Owais

I'm an AIOps Engineer with a passion for AI, Operating Systems, Cloud, and Security—sharing insights that matter in today's tech world.

I completed the UK's Eduqual Level 6 Diploma in AIOps from Al Nafi International College, a globally recognized program that's changing careers worldwide. This diploma is:

  • ✅ Available online in 17+ languages
  • ✅ Includes free student visa guidance for Master's programs in Computer Science fields across the UK, USA, Canada, and more
  • ✅ Comes with job placement support and a 90-day success plan once you land a role
  • ✅ Offers a 1-year internship experience letter while you study—all with no hidden costs

It's not just a diploma—it's a career accelerator.

👉 Start your journey today with a 7-day free trial

Related Articles

Continue exploring with these handpicked articles that complement what you just read

More Reading

One more article you might find interesting