In order to start tracking these files, we need to tell git which ones we want to track. We do this with the "git add " command.

To track the "CHANGELOG.txt" file, I'll type "git add CHANGELOG.txt".

Now, when I type "git status", we'll see the heading "Changes to be committed", and under that the message "new file: CHANGELOG.txt". This means that when we make our next commit, the CHANGELOG.txt file will be included in that commit. The rest of the files under the "Untracked files" heading will not.

When a file is added with the "git add" command, but not yet committed, it's what's known as a "staged" file. It's ready to be committed, but isn't yet, so that you can verify the correct files will be committed when you run the commit command.

When you start a new repository, you typically want to add all existing files so that your changes will all be tracked from that point forward. So, the first command you'll typically type is "git add ." (the "." means, this directory. So, it will add everything in this directory.)

I'll type "git add ." and press Enter.

This time, it takes just a bit longer because it's processing all of the files in this directory, and every directory inside it.

Once that's done, I'll type "git status" again, and we'll see that git has added every single file in the Drupal directory.

Well, that's not actually true. It looks like it did, but there are a couple of exceptions. Git won't track empty directories, or files that are configured to be ignored based on the rules in a ".gitignore" file, like the one that Drupal comes with.

First I'll demonstrate that Git will ignore empty directories by creating one named "Empty".

I'll type "mkdir Empty" and press Enter.

Now, when I type "git status", there's no mention of a new untracked directory, and it's not in the list of staged files. If I were to create a text file inside the Empty directory, Git would pick that up.

  • I'll type "vi Empty/test.txt" and press Enter.
  • I'll press the "i" key and type "This is a test document."
  • Then, quit the file by pressing the escape key and typing ":wq" and pressing Enter

Now, when I type "git status", we'll see the "Empty" directory in the list of Untracked files. So, since it's no longer empty, Git will add it to the repo.

I'll delete the Empty directory, and all its contents by typing "rm -rf Empty" and pressing Enter.

Now, let's take a look at the .gitignore file to see what is being ignored and why.