Publish your code to a website
In this task, you’ll use a special feature of GitHub to publish your work to the web.
Now we’re going to publish your work to a website using GitHub Pages, so that you can demo your work. If you have a git branch called
<username>.github.io. You can use this for any static content, but not for applications that require a server.
In the terminal, change to your project folder and type
to see a list of your branches. You should see only one branch called
Now create a new branch called
gh-pages, like this:
git branch gh-pages
This tells git to make a new branch called
gh-pages based on your current branch (which is
git branch again. What do you see? Does
git branch tell you which branch you are on?
To move into your new branch, type:
git checkout gh-pages
Any commits you make now will be on the
gh-pages branch (and won’t show up on
master). You’ll be using this branch to publish the work you are doing to GitHub Pages.
Publishing using GitHub Pages
To push this branch to GitHub type:
git push origin gh-pages
GitHub notices that you’ve pushed a branch called
After you’ve done this you should checkout the master branch again by doing:
git checkout master
Files we don’t need git to watch
Let’s learn a bit more about another part of git: ignoring files.