babycoder
babycoder

Reputation: 180

Deploy project to gh-pages from a git clone

I have a project that I need to deploy into github pages and add the link to my README. I cannot figure out how to do that from a cloned repository. I created the gh-pages branch using Terminal and then I switched into it and tried pushing it to master but my git hub is still only showing the master branch.

I also tried creating a new repository but I cannot seem to push it on there either.

Upvotes: 1

Views: 585

Answers (1)

VonC
VonC

Reputation: 1326782

Since August 2016 and GitHub "simpler GitHub Pages publishing", you don't have to use the gh-pages branch if you don't want to:

As long as your repo is named <username>.github.io (replacing <username.github.io> with your actual GitHub username), you could simply add a docs folder and put your files there, still pushing to master.

But if you are using gh-pages, you can create an orphan branch and put your project files in it:

cd /path/to/my/username.github.io
git checkout --orphan gh-pages
git rm -rf .
rm '.gitignore'
echo "#Title of Readme" > README.md
git add README.md
git commit -a -m "Initial Commit"
git push -u origin gh-pages

Then add your project files, commit and push.

Upvotes: 2

Related Questions