Master Git Hub Programming From Scratch

Clear, interactive, and structured coding lessons designed for absolute beginners.

Tracking Changes

To manage your project effectively, you need to understand how Git handles tracking changes inside your working directory. Git views every file in your project folder as either Tracked or Untracked.

Below is how Git monitors your files and how you can manage them.

Tracked vs. Untracked Files

  • Untracked Files: Any new file you create that Git has never seen before. Git will not include it in any snapshots until you explicitly tell it to.

  • Tracked Files: Files that were included in your last commit. Git knows about them and monitors them for three specific lifecycle changes:

    • Unmodified: The file has not changed since your last commit.

    • Modified: You have edited the file since your last commit.

    • Staged: You edited the file and ran git add to prepare it for your next snapshot.

2. The Staging Area / Index (Staged State)

The staging area is a hidden file that stores information about what changes will go into your next commit. You move files here using the git add command.

  • State: Staged: The changes are marked in their current version to go into your next history snapshot.

  • Analogy: A shipping box. You are packing specific items into the box, but you haven't taped it shut or shipped it yet.

3. The Git Directory / Repository (Committed State)

This is where Git permanently stores your project's metadata and object database (the hidden .git folder). When you use git commit, everything in your staging area is safely locked into the project's history.

  • State: Committed: The data is securely stored in your local database.

  • Analogy: The shipping box is taped, labeled, and securely stored in the warehouse.

The Workflow in Action

Step Command What it does State Change
Edit Modify code in your editor Changes files on your computer. Working Directory → Modified
Stage git add {filename} Prepares specific changes for a snapshot. Working Directory → Staging Area
Commit git commit -m "Message" Permanently saves the staged snapshot. Staging Area → Git Directory

Checking Your Current States

You can see which files are in which state at any time by running:

git status
  • Red text means files are in your Working Directory (Modified/Untracked).
  • Green text means files are in your Staging Area (Staged and ready to commit).