Adding a new set of Pages for a project manually is a straightforward process if you're used to using command-line git.
Play it safe
Setting up Pages on a project requires a new "orphan" branch in your repository. The safest way to do this is to start with a fresh clone.
git clone https://github.com/user/repository.git # Clone our repository # Cloning into 'repository'... # remote: Counting objects: 2791, done. # remote: Compressing objects: 100% (1225/1225), done. # remote: Total 2791 (delta 1722), reused 2513 (delta 1493) # Receiving objects: 100% (2791/2791), 3.77 MiB | 969 KiB/s, done. # Resolving deltas: 100% (1722/1722), done.
Let’s get crackin’
Now that we have a clean repository, we need to create the new branch and remove all content from the working directory and index.
cd repository git checkout --orphan gh-pages # Creates our branch, without any parents (it's an orphan!) # Switched to a new branch 'gh-pages' git rm -rf . # Remove all files from the old working tree # rm '.gitignore'
Tip: The gh-pages
branch won't appear in the list of branches generated by git branch
until you make your first commit.
Now we have an empty working directory. We can create some content in this branch and push it to GitHub. For example:
echo "My GitHub Page" > index.html git add index.html git commit -a -m "First pages commit" git push origin gh-pages
Tip: After the first push, it can take up to ten minutes before the content is available.