The first thing we're going to do is create a directory for our
project. You can call this directory anything and put it
anywhere on your machine, it doesn't matter. I'm currently in
the projects directory. So let's create a directory called moon,
and then go into this directory. So let's imagine this is our
project directory. and here we can have 10s, or hundreds of
files.
The first time we want to add this file to a git repository,
we have
to initialize a new empty repository. So we type Git in
it, look at this message, initialized, empty Git
repository in and here's the full path. So we have the moon
directory. And inside this directory, we have a
subdirectory called dot Git. And, by default, this
subdirectory is hidden because you're not supposed to touch it.
So if we type ls to list all the files and directories here, we
don't see anything. But if you type ls dash A, which is short
for all, we can see the Git sub directory If you're on Mac, you
can open this with Finder. And if you're on Windows, you can
open it with Windows Explorer or File Explorer. I'm not sure why
it's called these days. So let's open .git take a look.
So here's our Git directory or Git repository. This is where
Git stores information about our project history. So we have
directories like branches, hooks, info, objects, and
references. Now someone using Git, you don't really need to
understand this structure. This is purely implementation detail.
It's how Git stores information. It's none of our business.
That's why this directory is hidden so you don't touch it. If
you corrupt or remove this directory, you're gonna lose
your project history. Let me show you. So back in the
terminal, look at this green marker. It says Git that means
we have a git repository in this directory. Now if you want to
have a pretty colorful terminal window like this on mac you need
to install zelis H or z shell and on Windows, you need to
install poshkit but don't worry about it. Now, these tools are
completely optional to use. Git is just for making things
pretty. So here we have a git repository. Now, if I remove the
Git subdirectory, we're going to lose this repository. So RM dash
RF .Git, look, the green mar er is gone. We don't have a git
repository here anymore. So don t touch this directory. Now once
again, let's initialize a Git repository. Beautiful. So now
that we have a repository. Next we're going to talk about the
basic Git workflow.