Run git status to List Untracked
In this step, we will use the git status
command to see how Git tracks files and identifies those it doesn't know about yet.
First, make sure you are in your my-time-machine
directory. If you are not, use the cd
command:
cd ~/project/my-time-machine
Now, let's create a new file in this directory. We'll call it notes.txt
:
echo "Ideas for future projects" > notes.txt
This command creates a file named notes.txt
and puts the text "Ideas for future projects" inside it.
Now, let's ask Git about the status of our repository:
git status
You should see output similar to this:
On branch master
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: message.txt
Untracked files:
(use "git add <file>..." to include in what will be committed)
notes.txt
Notice the "Untracked files:" section. Git sees that a new file, notes.txt
, exists in the directory, but it's not part of the repository's history yet. Git doesn't automatically track every file you create. This gives you control over which files are included in your version control.
Why is this important? Imagine you have temporary files, build outputs, or personal notes in your project directory. You wouldn't want these cluttering your project's history. Git's "untracked" status allows you to keep these files separate from the files you are actively managing with version control.
In the next step, we'll explore another way to list these untracked files.