Test Untracked Files
In this step, we will create a new file in our my-time-machine
directory and see how Git's status changes to reflect the presence of an untracked file.
Make sure you are in the ~/project/my-time-machine
directory.
Create a new file called notes.txt
using the echo
command:
echo "Some random notes" > notes.txt
This command creates a new file named notes.txt
and writes the text "Some random notes" into it.
Now, let's check the status of our repository again using git status
:
git status
You should see output similar to this:
On branch master
Untracked files:
(use "git add <file>..." to include in what will be committed)
notes.txt
nothing added to commit but untracked files present (use "git add" to track)
Notice the "Untracked files:" section. Git has detected the new file notes.txt
but is telling us that it is not being tracked. This is because we haven't told Git to include this file in our repository's history yet.
This is a key concept in Git: you have to explicitly tell Git which files you want to track using the git add
command. This prevents Git from automatically including every single file in your directory, which might include temporary files, build artifacts, or personal notes that you don't want in your project's history.
In the next lab, we will learn how to add this new file to the staging area and commit it, making it a tracked file in our repository.