CodeBlanks Logo Icon CodeBlanks

Tracked

Learn the tracked file state.

What is a tracked file?

Files that Git monitors are called tracked files. If a file has been committed before or added to the staging area, Git includes it in the tracking process. When you modify a tracked file, Git can detect the change.

# A change in a tracked file
README.md

Tracked files can have states such as committed or modified over time.

Committed and modified states

The committed state means that the current version of a file exists in a commit in Git history. When you edit the file, its working copy differs from the committed version and Git detects it as modified. You can stage the change with git add and create a new commit.

# Stage the change
git add README.md

The file continues to be tracked throughout this process.

Practice Prepare a change for a new commit

You modified the previously committed profile.html file. Write the command that stages this change.

Starter code

terminal
# Değişikliği sahneye ekle

Sample solution

terminal
# Değişikliği sahneye ekle
git add profile.html

Expected output

git add profile.html

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 What is the state of a previously committed file after you make a change that has not been committed yet?

  • New repository
  • Ignored
  • Untracked
  • Modified Correct answer

Explanation: The file is already tracked, so it is not untracked. A change after the last commit makes it modified.

2 Stage a modified file

Question
git add ____
Answer
git add README.md

Explanation: The <code>git add README.md</code> command stages the change in the tracked file.

3 Tracked file states

Term Meaning
Tracked Monitored by Git
Committed Recorded in commit history
Modified Changed after the last commit
git status Displays file states

All lessons in Beginner