Using Git

As mentioned earlier, Git is responsible for keeping track of the changes to our project, but by default it doesn't actually track any of our files. We have to tell Git exactly which files we want it to keep track of and there's a good reason for this. There are files in every project that we're most likely not going to want to add to our Git repo, and we'll talk about which ones and why later. For now let's go ahead and run the following command:

git status

Now all these commands need to get executed from inside of the root of the project. If you try to run this outside a repository, you'll get an error like git repository not found. What that means is that Git cannot find that .git directory in order to actually get the status of your repository.

When we run this command, we'll get some output that looks like this:

The important pieces for now is the Untracked files header and all of the files underneath it. These are all of the files and folders that Git seized, but it's currently not tracking. Git doesn't know if you want to keep track of the changes to these files or if you want to ignore them from your repository.

Now the views folder, for example, is something we definitely want to keep track of. This is going to be essential to the project and we want to make sure that whenever someone downloads the repository, they get the views folder. The log file on the other hand doesn't really need to be included in Git. In general our log files are not going to be committed, since they usually contain information specific to a point in time when the server was running.

As shown in the preceding code output, we have server.js, our public folder, and package.json. These are all essential to the process of executing the app. These are definitely going to be added to our Git repository, and the first one above we have is the node_modules folder. The node_modules folder is what's called a generated folder.

Generated folders are easily generated by running a command. In our case, we can regenerate this entire directory using npm install. We're not going to want to add Node modules to our Git repository because its contents differ depending on the version of npm you have installed and depending on the operating system you're using. It's best to leave off Node modules and let every person who uses your repository manually install the modules on the machine they're actually going to be running the app.