There are two ways to create a new Git repository. You can make the directory that you are currently in a Git repo, or you can create a new directory that is itself a Git repo. I'll demonstrate:

Creating a New Directory as a Git Repository

Let's create a new Git repository inside the Downloads directory, and name it "GitRepo". First, I'll move into my "Downloads" directory by typing "cd ~/Downloads". Then I'll create the repo by typing "git init GitRepo".

When I do that, you'll see the message

Initialized empty Git repository in /Users/ModulesUnraveled/Downloads/GitRepo/.git/

What this is saying is that there is a new directory at "/Users/ModulesUnraveled/Downloads/GitRepo" and that this folder is setup to be tracked by Git. We know it's setup to be tracked because the ".git" directory is a hidden folder which contains the configure for and information about this repository.

We can now move into our new directory by typing "cd GitRepo" and pressing Enter.

If we type "ls -al", we'll see the hidden ".git" directory (we know it's hidden because it starts with a "." (a dot).) And if we type "ls -al .git" to see the files inside the ".git" directory, we'll see all of files that are used by Git to make this repo work. We won't be editing any of these files directly, so you don't need to worry about them. Just know that the presence of the ".git" directory

Let's delete the GitRepo folder, and make an existing folder a Git repo.

To delete it, I'll move up into the "Downloads" directory by typing "cd .." and then delete the folder by typing "rm -rf GitRepo".

Making an Existing Directory a Git Repository

Now, I'll take an existing Drupal site and make it a Git repository so that I can keep my code changes (like module installations and theme updates) in version control. I'll move to my sites directory with "cd /var/www". Here I have a folder "mygitwebsite" which is a standard Drupal 7 installation.

Let's move into that directory and make it a Git repo with the "git init" command.

I'll type "cd mygitwebsite" in the terminal, and then when I type "ls", we'll see the standard Drupal files.

Now, I can make the "mygitwebsite" directory a Git repository by typing "git init".

When I do that, you'll see the message

Initialized empty Git repository in /Users/ModulesUnraveled/kalabox/www/mygitwebsite/.git/

This confirms that this folder is setup to be tracked by Git. We know that because of the presence of the ".git" directory, which contains the configure for and information about this repository.

Using "git status" to View the Status of the Repository

We can use the "git status" command to see what files are untracked, staged and committed in this repository. Since we just created this one, we haven't added or committed anything, so everything should be untracked, but let's take a look.

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

When I do, you'll see all of the files under the "Untracked files" heading, and the text "nothing added to commit but untracked files present". This means that none of the files are being tracked right now so Git isn't actually doing anything for us.

In the next video, we'll make Git aware of these files so that it can start tracking them and we can begin to take advantage of what Git offers.