Github Pages
Create a simple Github User repository
In this exercise we will be creating a new git
repository remote at
Github.
Create a New Respository
- Navigate your web browser to https://github.com/new.
- For the Repository Name, enter
username.github.io
. Use your actual username, or this will not work! - Make the repository Public.
- Check the Initialize this repository with a README option.
Fire Up Your Terminal
In this step, you will download (clone
) the files in the repository
you just created.
Create a project directory
In the terminal, create a new directory (mkdir
) and navigate to it
(cd
).
Clone the Repository
Go back to your browser that has the newly created repository. On the right-hand side, you’ll see a section that says “SSH clone URL”. Copy the contents or just replace the following with your valid information.
Check Your Directory
We can check out the contents of the directory. We should have a
directory with just a single file. We can check this in the terminal by
listing (ls
) the files in the directory.
But are those the only files? What happens if you pass the -a
flag to
ls
?
Creating a New File
We will keep this pretty light, for now. We will create an exceptionally simple web page and push it back to Github.
Create a new file with your name in it in the terminal using the
concatenate command (echo
) and output redirection (>
).
Now we need to check the status of the repository.
Reading the message, we see we need to run git add
since this is a new
file. If we run git
status
after adding the file, we’ll see its status has changed.
Git now knows that you want to track the file, but now we actually have to commit the change to the database, with a message about what we did at this point.
Now we can push the master branch of the repository to Github. When we cloned
the repository, git
automagically set a remote of “origin” for us.
A Github Page
Refresh the repository page you had open. You should see the
index.html
file you just created. Now, here’s the crazy part…point
your browser to http://username.github.io (where username is your
username). What happens?
Recap
Congratulations, you just did a full development cycle! You created a
new repository to share your code, cloned it to your development
environment, created new content, and pushed/deployed your code. You
also saw that there are several stages of using git
…adding new files
and committing them to the git repo. These two steps have to happen
before you’re able to push
the code to the server to share. This can
be a bit confusing at first, but the git status
command will always
tell you what stage you are at in the process.