Test Non-Indexed Files
In this step, we will create a new file in our working directory and observe how Git recognizes it before it's added to the index. This will help you understand the difference between files in your working directory and files in the index.
First, make sure you are in the my-time-machine
directory:
cd ~/project/my-time-machine
Now, let's create a simple text file using the echo
command:
echo "This is a new file." > new_file.txt
This command creates a file named new_file.txt
and writes the text "This is a new file." 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
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
new_file.txt
nothing added to commit but untracked files present (use "git add" to track)
Notice the "Untracked files:" section. Git sees that new_file.txt
exists in the working directory but is not being tracked by Git yet. This means it's not in the index and it's not part of any commit history.
This is a key concept: Git only tracks files that you explicitly tell it to track using git add
. Any new files created in a Git repository's working directory are initially "untracked".
In the next step, we will add this file to the index, preparing it for our first commit.