Last Updated: August 01, 2023
·
1.107K
· fadamiao

Push only the gh-pages branch

The intent of this tip is show how to push only the gh-pages branch in GitHub. This is useful cause with gh-pages branch GitHub host a static website.

git init
git add .
git commit -m "First inclusion of files"
git branch -m master gh-pages
git remote add origin git@github.com:<USER>/<REPOSITORY>.git
git push origin gh-pages

The trick is git branch -m after git commit, -m in git branch command change the name of the branch. You can check this with git status and push.

Note in git push command after origin is gh-pages branch.