从另一个分支的子目录更新一个分支的根目录

问题描述 投票:0回答:1

在 github 上进行开发时,我经常在 master 分支中维护一个

html/
_site/
子目录,在其中为项目生成基于 Web 的文档。 我想切换到 gh-pages 分支,并将
pull
目录的内容放入 gh-pages 分支的根目录中,这样它将通过 github 呈现为一个不错的网站(它自动呈现 html在
html
gh-pages
)。 执行此操作的最佳工作流程是什么?
如果我还没有设置 gh-pages 分支,我可以分支、清除分支,然后复制 

username.github.com/repositoryname

目录的内容,很快,我就已经准备好了一个站点。 但我不确定如何最好地更新 gh-pages 分支。

html

现在我应该怎么做才能更新 gh-pages 分支?  听起来这可能涉及
子树合并

,但我不太确定。

git github
1个回答
14
投票

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

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

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

你就完成了。

后期添加:添加到 gh-pages 分支的顺序更短:

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

不需要刷新当前工作树

© www.soinside.com 2019 - 2024. All rights reserved.