Github: Mirroring gh-pages to master

后端 未结 8 2089
伪装坚强ぢ
伪装坚强ぢ 2020-12-12 09:27

I\'m developing a jQuery plugin that\'s being hosting on GitHub. It has a demo included of which I\'m manually copying and pushing to the branch gh-pages, what

8条回答
  •  爱一瞬间的悲伤
    2020-12-12 10:25

    UPDATE: GitHub now allows pages to be published from any branch and directory you want.


    It was much easier for me to use the gh-pages branch as master. There's nothing magical about "master"; it's just another branch name. There is something magical about gh-pages, because that's where GitHub is looking for index.html to serve your page.

    Read more in my other answer on this topic.

    Using gh-pages as master is also easier than subtrees, which are easier than mirroring. You could use git subtree as described here or here: if you have a directory which contains your demo, you can push that directory to the gh-branch with one command. Let's say you name the directory gh-pages to make things clear. Then after you've committed and pushed your changes to master, run this to update gh-pages:

    git subtree push --prefix gh-pages origin gh-pages
    

    The problem is if your files in gh-pages refer to files in other directories outside it. Symlinks don't work, so you'll have to copy files in the directory that serves as gh-pages.

    If you use gh-pages as master, this problem won't occur.

提交回复
热议问题