从另一个分支的子目录更新分支的根目录 [英] Update the root directory of a branch from the subdirectory of another

查看:46
本文介绍了从另一个分支的子目录更新分支的根目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在github上进行开发,经常在我的master分支中维护一个html/_site/子目录,在该子目录中我为该项目生成基于Web的文档.我想切换到gh-pages分支,将html目录的内容仅切换到gh-pages分支的根目录,因此它将通过github呈现为一个不错的网站(它将自动呈现html在username.github.com/repositorynamegh-pages中).最好的工作流程是什么?

Developing on github, I often maintain a html/ or _site/ subdirectory in my master branch where I generate web-based documentation for the project. I'd like to switch to my gh-pages branch and pull just the contents of this html directory into the root of the gh-pages branch, so it will render as a nice website through github (which automatically renders html in gh-pages at username.github.com/repositoryname). What is the best workflow to do this?

如果尚未设置gh-pages分支,则可以分支,清除分支,然后复制html目录的内容并保存,然后准备好一个站点.但是我不确定以后如何最好地更新gh-pages分支.

If I don't yet have the gh-pages branch set up, I can branch, clear the branch, and copy in the contents of the html directory and presto, I have the a site ready to go. But I'm not sure how best to later update the gh-pages branch.

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分支?听起来这可能涉及子树合并,但我我不太确定.

Now what should I do to update the gh-pages branch later? It sounds like this might involve subtree merging but I'm not quite sure.

推荐答案

启动gh-pages分支:

To start your gh-pages branch:

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

要获取您想要的任何内容,请说说master分支中的html目录,读取树并提交:

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

您完成了.

最新添加:向gh-pages分支添加的顺序更短:

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

不需要刷新当前工作树

这篇关于从另一个分支的子目录更新分支的根目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆