init: git add
In this video we'll learn how to track changes with
Once we have a Git repository we'll want to start tracking changes.
Changes are not automatically tracked by Git.
This is an important difference from other version control systems.
With Git, you have to specify which changes to track.
You do so with
First, let's make a few files. I'm going to use the
touch command to do this quickly.
touch file-1.txt file-2.txt file-3.txt
We can confirm they were created by running
ls... And there they are.
git status to see the current state of the repository.
Git sees the files, but notice they are listed as untracked.
This means they have not been added to the Git repository and therefore Git will not track changes to these files.
Let's add File 1 by running:
git add file-1.txt
If we run
git status, we now see File 1 has moved from untracked (in red) to ready to be committed (in green).
Git now sees File 1 as a new file to add to the repository.
We can add multiple files by running:
git add .
If we run
git status again, we confirm that Git now sees all of the files.
There is more to learn about
git add, but this is as far as we can go without covering other Git commands.