From the course: Complete Guide to Git

Introducing the project - Git Tutorial

From the course: Complete Guide to Git

Introducing the project

- [Instructor] We used simple files while we were learning basic Git commands in the last chapter. You may want to keep that project around as a place where you can experiment. Going forward, we'll be working with a simple website instead. It will better reflect what it's like to use Git with actual projects. You can follow along with the same website, which is in the course exercise files, or you could use one of your own projects instead. In either case, I recommend working with a copy of the original files so that you can feel free to experiment and make mistakes. Let's look at the new project files together. The project is called Big Star Collectibles. The project directory contains a basic website. There's some HTML pages, a few text files, and directories for the CSS, images, and JavaScripts. To view it, you can open the Index.html file in a browser. I'll just drag that file on top of Firefox. You can click around to view different pages, and you'll quickly notice that this is a design prototype that's missing some pages and features. Most likely, the final website would connect to a database or some type of e-commerce software. This design prototype is complete enough for our purposes. Git is not tracking any of the files in the new project yet. We can see that if we go over here to the command line and we navigate into the project. I'm still in my old project. I can use cd with dot dot to go backwards one directory or up into the parent directory, and then into Big Star Collectibles, or you could type cd and then just type in this full path, or you might be able to type cd and drag that directory in there and hit return to get in there. Once you're inside this new project directory, we can type git status and Git comes back and tells us this is not a repository and it's not a subdirectory of any repository, and it knows that because it did not find that special .git directory that Git uses to store its changes. We can see that if we type ls -la, or on Windows, that would be dir//ah, and it'll give us a list of what's in that directory, and you can see that there is no .git file. It would be right before cart, because these are alphabetical. So this directory is not a Git repository or a subdirectory inside a Git repository. We need to initialize it first, and we'll do that with git init, and now this is a Git repository, ls -la again or dir//ah, and now we see that Git directory has been created. If I type git status, Git tells us that this is a Git directory. It no longer complains. We're on branch main, there's no commits yet, but Git noticed that there are untracked files present. So let's add them, git add, and we'll use period to say everything that's in the current directory. git status now will report a long list of files that it's got ready to be committed and so let's use git commit, it'll open up my text editor, and it will ask for a commit message. It's very common to use initial commit for the first commit with an existing project. We're adding these files as is to the directory. There is no information available about the prior changes that created these files, but we're going to be tracking changes going forward from here. So we'll just start with initial commit. I'll save this and close the file and the text editor now adds them. If I type git status, you can now see that everything has been committed. Now in case it's not clear, this is a separate get repository from the one we used in the previous chapters. We can have many Git repositories on our computer and each one will track its changes separately. When you navigate into each project directory from the command line, you'll be using the repository that's configured in that directory. In general, I don't recommend moving one repository inside another one, either. Keep each project directory and its repository separate. If I come back over here and I type git log, we'll see our first commit, so we've now initialized it and added all the project files to the repository and Git is ready to track our changes to the project.

Contents