In git, is there a simple way of introducing an unrelated branch to a repository?

前端 未结 9 2067
被撕碎了的回忆
被撕碎了的回忆 2020-11-22 06:11

While helping a friend with a git problem today, I had to introduce a branch that needed to be totally separate from the master branch. The contents of this bra

9条回答
  •  北海茫月
    2020-11-22 06:51

    The currently selected answer is correct, I would just add that coincidentally...

    This is actually exactly how github.com lets users create Github Pages for their repos, thru an orphaned branch called gh-pages. The pretty steps are given and explained here:

    https://help.github.com/articles/creating-project-pages-manually

    Basically the git commands to set this up are as follows:

    1. git checkout --orphan gh-pages (create a parentless branch called gh-pages on your repo)
    2. git rm -rf . (removes any files from branch working tree)
    3. rm '.gitignore' (even the gitignore)
    4. Now add website content (add index.html, etc) and commit and push.
    5. Profit.

    Note you can also designate a /docs folder on you repo to be the source of the "Project Site" that Github uses to build the website.

    Hope this helps!

提交回复
热议问题