Update the root directory of a branch from the subdirectory of another

后端 未结 1 1205
不思量自难忘°
不思量自难忘° 2020-12-05 15:24

Developing on github, I often maintain a html/ or _site/ subdirectory in my master branch where I generate web-based documentation for the project.

相关标签:
1条回答
  • 2020-12-05 16:04

    To start your gh-pages branch:

    true | git mktree | xargs git commit-tree | xargs git branch gh-pages
    

    To fetch anything you want into it, say the html directory from the master branch, read-tree and commit:

    git checkout gh-pages
    git read-tree master:html
    git commit -m'gh-pages documentation'
    git push origin gh-pages
    git checkout master
    

    and you're done.

    Late addition: there's a shorter sequence for adding to the gh-pages branch:

    git commit-tree -p gh-pages -m "" master:html \
    | xargs git update-ref refs/heads/gh-pages
    

    which doesn't require flushing the current working tree

    0 讨论(0)
提交回复
热议问题