Setting up the repository

Now, out of the preceding three setup instructions, we don't need the one for creating a new repository. We are not going to use the one for importing our code from some other URL. What we have is an existing repository and we want to push it from the command line.

We'll run these two commands from inside our project:

Remotes let Git know which third-party URLs you want to sync up with. Maybe I want to push my code to GitHub to communicate with my co-workers. Maybe I also want to be able to push up to Heroku to deploy my app. That means you would want two remotes. In our case, we'll just add one, so I'll copy this URL, move into the Terminal, paste it, and hit enter:

git remote add origin https://github.com/garygreig/node-course-2-web-server.git

Now that we have our git remote added, we can go ahead and run that second command. We'll use the second command extensively throughout the book. In the Terminal, we can copy and paste the code for second command, and run it:

git push -u origin master

As shown in the preceding screenshot, we can see everything went great. We were able to successfully write all of our data up to GitHub, and if we go back into the browser and refresh the page, we're no longer going to see those setup instructions. Instead, we're going to see our repository, kind of like a tree view:

Here we can see we have our server.js file, which is great. We don't see the log file or node_module file, which is good, because we ignored that. I have my public directory. Everything works really really well. We also have issues tracking, Pull requests. You can create a Wiki page which lets you set up instructions for your repository. There's a lot of really great features that GitHub has to offer. We'll be using just the very basic features.

On our repository, we can see we have one commit and if we click on that one commit button, you can actually go to the commits page and here we see the initial commit message that we typed. We made that commit in the previous section:

This is going to let us keep track of all our code, revert if we make unwanted changes, and manage our repository. Now that we have our code pushed up, we are done.