git: put a branch in a subdirectory

后端 未结 6 1490
北恋
北恋 2021-02-04 00:35

I have a git repository (at github.com) with two branches: master and gh-pages. I would like to have the gh-pages branch in a subdirectory, so that I don\'t need to switch branc

6条回答
  •  眼角桃花
    2021-02-04 01:13

    I've tried the git subtree trick, but it requires that master have all the gh-pages content committed to it, which is not ideal in this case. Much better and simpler is to

    1. Create a new directory at ./repo/gh-pages/
    2. Put a line on .gitignore for that (gh-pages)
    3. cd gh-pages/, git init and git checkout -b gh-pages, creating an independent git remote there

    You can also git clone directly to ./gh-pages/ with only the branch you want.

提交回复
热议问题