Monday, October 20, 2014

Baby's First Git Repository, Part I

If you're jut starting to learn to code, you probably know what it is like to be in the icy grip of abject terror, brought on by exposure to git. (If not, either you will be soon, or you're a better man than I.)

In the earlier times, and for quite some time, I felt like anything git that I tried was probably going to result in explosion, followed by the simmering liquefaction of my laptop. (Thankfully, this has not yet happened.)

In the hopes of assuaging any git-related feelings of impending doom you might have, I have prepared a step-by-step guide to creating a git repository (git repo, for short).

There are two phases of creating a git repository - locally, via the command line, and on GitHub*.

First things first - the command line. We'll need to having a working directory for our project, so we'll start there. Let's say, for the sake of awesomeness, that we want to make Paula Abdul fan site. We need a directory on your machine, in which to keep our files, so let's go make that. Once we've opened a terminal window, we'll use the mkdir command, which is short for "make directory", and we'll name the directory "paula-fan". Like so:




Next, you want to make sure you're in that directory, so you'll use the cd command, which in this case refers not to obsolete data storage or the lovesick musical mixes of your youth, but rather to "change directory".



Okay. Now you're all up in your Paula Abdul directory. It isn't strictly necessary at this point, but let's go ahead and create a file named "index.html" in there, just to show what that looks like. For reasons unbeknownst to me, the command for this is touch, which is short for...? I don't know, but this is what it looks like:




Now we're at the starting point for the process of making the repo. We'll use git init (short for "git initialize"):




Next, we'll commit what we have so far. Commit basically means we're saving the current version of our work locally (i.e. on our machine). Once we're done creating the repo, we'll push your committed files to your new repo - meaning, we'll send all the stuff we committed locally on up to the repo. But I'm getting ahead of myself. Let's take care of that commit first. We'll use "git add ." The add part is for for saying what files you want to commit; the "." is saying that we want all of them. Here's what it looks like:




Next, we'll do the actually committing. We'll use git commit command, and add a message to remind ourselves what was new in this version. Since this is the very first commit of paula-fan's short life, the message won't have much in it:




At this point, we've done all we need to do on this end for now. In the next post, we'll straight up take a field trip to GitHub, and take care of the other end of setting up your awesome Paula Abdul repository.




*Or any site optimized for hosting git repositories. GitHub is the most commonly used, but if you prefer your version control to taste less like sexism, other solid options like BitBucket and GitLab exist.

No comments:

Post a Comment