如何在一个分支中构建文档并自动将 build/html 复制到 gh-pages 分支
Github 将项目网站存储在项目存储库的单独分支(gh-pages)中。 我们在 master 中有一个 sphinx 包来构建我们的文档,并希望自动将生成的文档提交到 gh-pages 分支。
Sphinx 配置和源不能位于 gh-pages 分支本身,因为该分支仅包含 html。如果主版本没有自行版本化 html,则会看到这一点(使用 .git 忽略,如下所示 如何将特定目录提交到与 git 上的工作分支不同?)。如果是版本会发生什么。
我想输入 makepublish 并让它构建文档(我们已经将其作为 make 目标),然后将这些更改应用到 gh-pages 分支(实际上是强制的)。
问题是 gh-pages 实际上是 doc/build/html 的内容,因此标准合并似乎不起作用。
隐藏更改、更改分支以及应用冲突结果,并且似乎无法指定 --our 的合并策略。
子树合并和此类技术似乎旨在合并外部存储库,而不是同一存储库中的内容。
Github stores project websites in in a seperate branch (gh-pages) of the project repository.
We have in master a sphinx package that builds our docs and want to automatically commit the generated docs to the gh-pages branch.
Sphinx config and the source cannot be in the gh-pages branch themselves because that branch contains only html.If the master didnt' version the html it self, this would be see(use .git ignore as shown here How can I commit specific directory to a different than a working branch on git?). What happens if it is version.
I want to type make publish and have it build the docs ( we have this as a make target already) and then apply those changes to the gh-pages branch (forcibly in fact).
The problem is that gh-pages is effectively the contents of doc/build/html , so a standard merge would seem not to work.
stashing the changes,changing branches, and applying results in conflicts and there appears to be no way to specify a merge strategy of --ours.
Sub-tree merging and such techniques appear to be intended for merging external repositories, not things in the same repo.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我发现这些步骤对于发布到不同的分支(例如
gh-pages<)非常有用/代码>。你可以谷歌一下其他一些脚本,但这个似乎写得更清楚。
一般步骤是:
- 将当前的
outdir
添加到.gitignore
- 将整个存储库克隆到
outdir
以在那里启动 .git,清理它并创建一个gh-pages
分支- 制作一个从outdir推送的构建。
您可以按照使用
master
和gh-pages
两个单独文件夹的代码此处,注释是俄语的,但命令是相当不言自明的。I found these steps very useful for publishing to a different branch like
gh-pages
. There are some other scripts you can google, but this one seemed more clearly written.Generally the steps are:
- add your current
outdir
to.gitignore
- clone whole repo to
outdir
to initiate .git there, clean it and make agh-pages
branch- make a build that you push from outdir.
You can follow the code that uses two separate folders for
master
andgh-pages
here, the comments are in Russian, but commands are rather self-explanatory.您可以创建一个空分支,并且只能在其中提交 html。
只需按照此处中的“项目页面”的 github 页面说明进行操作即可。
you can create a branch which is empty and where you can only commit your html's.
just follow the github pages instructions for "Project Pages" from here.