Initialize your first Git repository before you start tracking changes to files.
- [Instructor] Once you have Git installed and configured, the next step is to initialize Git in a project. The way we're going to do that is with a Git command which is git space init, I-N-I-T. That's short for initialize. So we're going to initialize a project to use Git using this command. Let's try it out. Now if we're going to initialize a project, we first need to have a project. So let's create a directory. This is going to be our project directory. It can be anywhere you want on your hard drive. Just put it someplace that's easy for you to find. I'm going to put mine in my documents directory. So inside my documents directory, there's nothing in there right now. I'm going to just create a new folder in there, and I'm going to call it first_git_project. So now I want to navigate in the command line to get to that directory. I'm in my user directory right now. So I need to go into my documents directory, and then I can use LS, or DIR if you're on Windows, to list the contents of that directory. You'll see that it contains that first_git_project. I want to go inside that project directory. So I'll use CD again, and I'll go inside first_git_project. Now I can type LS or DIR on Windows, and you'll see there's nothing inside there which is what we would expect, but I am now inside my project directory. You want to make sure that you're located inside that directory before you actually execute this command. I'm going to say git space init, hit return, and you'll see it comes up and tells us an initialized empty Git repository inside that project, and it tells you at the end. It says first_git_project.git/. Now if we look over here, you'll see there's nothing inside there. That's because of the dot file. These files with a dot don't show up by default. If we type ls-la, that will show it in the listing. So now we see a listing of all the files in the directory as well as files and directories that start with a period. This invisible Git directory is where Git is going to do all of its tracking. Having that directory lets us know that the Git repository has been initialized and is ready for us to use. In the next movie, let's talk a bit more about what goes inside that directory.
- Exploring the history of version control
- Installing Git on Mac, Windows, and Linux
- Initializing a repository
- Writing useful commit messages
- The Git three-tree architecture
- Tracking when files are added, edited, deleted, or moved
- Viewing change sets and comparing versions
- Undoing changes and retrieving previous versions
- Ignoring changes to select files