16
在github上开发时,我经常在我的主分支中维护一个html/
或_site/
子目录,在那里为项目生成基于Web的文档。我想切换到我的gh-pages分支和目录的内容到gh-pages分支的根目录,所以它将通过github呈现为一个漂亮的网站(它会自动呈现gh-pages
中的html username.github.com/repositoryname
)。什么是最好的工作流程?git:从另一个子目录更新分支的根目录
如果我还没有设置gh-pages分支,我可以分支,清除分支,并复制html
目录的内容,然后我就准备好了一个网站。但我不确定以后如何更新gh-pages分支。
git branch gh-pages
git checkout gh-pages
# Remove files I don't need from the gh-pages branch
rm -rf data/ man/ R/ README.md NEWS NAMESPACE DESCRIPTION demo/
# move documentation to the root
mv inst/doc/html/* .
# remove the rest
rm -rf inst/
git add *
git commit -a -m "gh-pages documentation"
git push origin gh-pages
git checkout master
现在应该怎么做才能更新gh-pages分支?这听起来像这可能涉及,但我不太确定。
会孤儿分支是同样合适吗? (http://stackoverflow.com/questions/7646487/starting-from-scratch-for-v2-0-should-i-keep-using-the-existing-git-repo-or-sta/7648343#7648343) – VonC
@VonC取决于你想要的。这样,你的gh-pages分支会保存历史记录,如果你的孤儿没有历史记录。在这里做孤儿的简单方法是'git commit-tree v1.6:html -mreset | xargs git分支-f gh-pages' – jthill
了解。无论如何,非常有趣的使用'git commit-tree'。虽然我不会赞成你的回答:我已经做到了。 – VonC