将文档提交给git分支(gh-pages) [英] Committing documentation to a git branch (gh-pages)

查看:120
本文介绍了将文档提交给git分支(gh-pages)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从javadoc的git项目工作目录的 / docs 目录中生成了文档。

I have generated documentation from javadoc in a /docs directory in the working directory of my git project.

我想通过将它提交到我的 gh-pages 分支来在 github.io (这会使它在 http://username.github.io/projectname 中自动可用)。

I would like to make this documentation available at github.io by committing it to the gh-pages branch of my repository (this will make it automatically available at http://username.github.io/projectname).

不知道该怎么去做。如果我通过使用 git checkout 切换到 gh-pages ,我的工作目录中的所有内容将切换到 gh-pages 的内容,对吧?这将从中删除 / docs 目录。

Not sure how to go about it, though. If I switch to gh-pages by using git checkout, all the contents of my working directory will be switched to the contents of the gh-pages, right? This will remove the /docs directory from it.

我可以复制 / docs 在其他地方复制到工作目录后切换到gh-pages,但这是否意味着我将不得不经过这个手动过程来复制 / docs code>,切换分支,再次复制,提交,切换回 master 分支,每次我想更新文档?我假设有一个更好的解决方案,但我不知道它可能是什么。

I could make a copy of /docs somewhere else and copy it to the working directory after switching to gh-pages, but does that mean I will have to go over this manual process of copying /docs, switching branches, copying again, committing, switching back to master branch, every time I want to update the documentation? I assume there is a better solution, but I don't know what it might be.

推荐答案

放入一个主人承诺的脚本),以达到相同的结果,它运作良好!

I use that (that I put in a script committed in master) to achieve the same result and it works well!

git commit -am "Save local changes"

git checkout -B gh-pages

git add -f docs

git commit -am "Rebuild website"

git filter-branch -f --prune-empty --subdirectory-filter docs && git push -f origin gh-pages && git checkout master

这篇关于将文档提交给git分支(gh-pages)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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