FREELessons: 24Length: 3.1 hours

Next lesson playing in 5 seconds

  • Overview
  • Transcript

2.1 Initializing a Repository

The first step in using Git initializing a Git repository, so that’s what we’ll do here. We’ll also talk about exactly what is created with said repository is initialized.

2.1 Initializing a Repository

Now that we have git installed and configured, we're ready to create our very first git repository. Of course, we'll start by opening a terminal, and I'm just gonna move to my desktop, and the first thing we wanna do is make a directory. We're just gonna call it project. This is gonna be our sample project for this screencast series. We're not actually going to create any real content in this project, but it will give us something to work with and allow us to learn the git commands without actually having to worry about the project we're building at the same time. So I'm gonna CD into that directory, and now we are ready to actually initialize a git repository. You'll recall from the previous screen cast that we start with the git command and then we have to give it a sub-command to tell git what we want to do. In this case, our sub-command is init, which as you can probably guess is short for initialize. However the command is just init and I'm gonna go ahead and run that. And now you can see we get the message, initialized empty repository and user sherlock/Desktop/project .git/. Notice the trailing slash on this, which implies that .git is actually a folder. So if I list all the files in this directory, we should see the .git folder, shouldn't we? Actually, we shouldn't see the .git folder because in Unix, all files and folders that begin with a dot are actually hidden. I would have to do ls -a to show all, and now you can see right here we have a .git folder. However, I happen to have the showing of hidden files and folders turned on in finder, so I'm just going to say open this directory and now right here you can see that we do indeed have a .git folder inside of our project directory. If I expand that, you can now see all the files and folders that make up the content of our git repository. This is where all the data is stored. Everything about the git repository stays within this one .git folder and these are the files and folders that make it all happen. We're not gonna actually look inside any of these right now, although we may come back to that in the future lessons. However I just wanted you to know that this is where all the functionality takes place. Consider this the database behind all the git tools that we're gonna be using. In fact, one of these files may seem familiar to you, the .git/config file. If you'll recall from our previous screen cast, that is where any local customization options are set. These are the options that are just set for this single repository. Now we're ready to create a readme file that will just act as a little bit of content for us to commit in our next screencast. There we go. We have a very small readme file. And I'm just gonna save and close that. And now we are ready to actually go on to learning how to commit files in to our repository and actually understand what committing actually means and how it works.

Back to the top