0
0
Gitdevops~10 mins

Untracked vs tracked files in Git - Visual Side-by-Side Comparison

Choose your learning style9 modes available
Process Flow - Untracked vs tracked files
Create new file
File is untracked
Run git add
File becomes tracked (staged)
Run git commit
File is tracked (committed)
This flow shows how a new file starts as untracked, then becomes tracked after adding and committing.
Execution Sample
Git
echo "Hello" > file.txt
git status
git add file.txt
git status
git commit -m "Add file.txt"
git status
This sequence creates a file, checks status (untracked), adds it, commits it, and checks status again.
Process Table
StepCommandGit Status Output SummaryFile State
1echo "Hello" > file.txtNo git output; file created in folderfile.txt created, untracked
2git statusShows: untracked files: file.txtfile.txt is untracked
3git add file.txtNo output; file stagedfile.txt staged (tracked)
4git statusShows: changes to be committed: new file: file.txtfile.txt staged (tracked)
5git commit -m "Add file.txt"[master (root-commit) abc1234] Add file.txt 1 file changed, 1 insertion(+) create mode 100644 file.txtfile.txt committed (tracked)
6git statusShows: nothing to commit, working tree cleanfile.txt tracked and committed
💡 After commit, file is tracked and no changes pending.
Status Tracker
File StateStartAfter Step 2After Step 3After Step 5Final
file.txtDoes not existUntrackedStaged (tracked)Committed (tracked)Committed (tracked)
Key Moments - 3 Insights
Why does the file show as untracked before running git add?
Because the file is new and git does not track it until you explicitly add it, as shown in execution_table step 2.
What changes the file from untracked to tracked?
Running git add stages the file, changing its state to tracked, as seen in execution_table step 3.
Why does git status show nothing to commit after the commit?
Because the file is now committed and there are no new changes, as shown in execution_table step 6.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the file state after running 'git add file.txt'?
AUntracked
BCommitted
CStaged (tracked)
DDeleted
💡 Hint
Check the 'File State' column at step 3 in the execution_table.
At which step does the file become committed?
AStep 5
BStep 2
CStep 3
DStep 6
💡 Hint
Look for the commit command and output in the execution_table.
If you create a new file but never run git add, what will git status show?
AFile is committed
BFile is untracked
CFile is staged
DFile is deleted
💡 Hint
Refer to the file state at step 2 in the execution_table.
Concept Snapshot
Untracked files are new files git does not track yet.
Run 'git add <file>' to stage and track them.
Run 'git commit' to save changes permanently.
'git status' shows file states: untracked, staged, committed.
Files stay untracked until added.
Full Transcript
When you create a new file in a git folder, it starts as untracked. This means git knows the file exists but does not track changes to it yet. Running 'git status' shows untracked files. To track the file, you run 'git add <filename>', which stages the file. Staged files are tracked and ready to be committed. After running 'git commit', the file is saved in the git history and is fully tracked. Running 'git status' after commit shows a clean working tree with no changes. This flow helps you understand how files move from untracked to tracked in git.