简体   繁体   English

将本地master *推入github上的* gh-pages分支

[英]push local master *into* gh-pages branch on github

I created a simple gh-pages branch on github and in my local repo. 我在github和我的本地仓库中创建了一个简单的gh-pages分支。 I used the auto page generator to create the 5 files it uses: images javascripts stylesheets index.html params.json 我使用自动页面生成器来创建它使用的5个文件:images javascripts stylesheets index.html params.json

I pulled this to my local repo and added js-markdown-extra.js to javascripts, and edited index.html to replace the "content" section with the compiled README.md created by the markdown library. 我把它拉到我的本地仓库并将js-markdown-extra.js添加到javascripts,并编辑了index.html以用markdown库创建的编译后的README.md替换“content”部分。

Putting in a dummy README.md showed it to work perfectly. 放入一个虚拟的README.md表明它可以完美地工作。

I want to then simply push my local master into (not onto ) the remote gh-pages branch, without modifying the 5 website files. 后来干脆把我的本地主 (不 )远程GH-页面分支,而不需要修改5个网站的文件。

I haven't found a way to do this. 我还没有办法做到这一点。 I was told via http://oli.jp/2011/github-pages-workflow/ that this would work: git push -f origin master:gh-pages 我通过http://oli.jp/2011/github-pages-workflow/告诉我这可以工作:git push -f origin master:gh-pages

I tried this on a test repo and it failed, resulting in a 404 (pushing the local gh-pages made for the markdown trick fixed that) 我在一个测试仓库上尝试了这个并且它失败了,导致了404(推送了为降价技巧修复的本地gh页面)

So is there a way to push master into , as a subset of, gh-pages? 那么没有办法将master作为gh-pages的子集推

Failing that, is there a simple way to merge the master into gh-pages locally without deleting the 5 website files? 如果失败了,有没有一种简单的方法可以在不删除5个网站文件的情况下将主页合并到本地gh页面?

I know how to "mirror" all this stuff so the 5 files would be in the repo but I'd like to avoid that clutter. 我知道如何“镜像”所有这些东西,所以5个文件将在回购中,但我想避免那种混乱。

From what I understand, you'd have to switch to your local copy of gh-pages. 据我所知,您必须切换到本地的gh页面副本。 Merge in master, and then push gh-pages 合并为master,然后推送gh-pages

git checkout gh-pages
git merge master
git push origin gh-pages

If I understand you correctly it seems that you created the dummy Readme and the other files on your local master branch but intended to have them on the gh-pages branch. 如果我理解正确,您似乎在本地主分支上创建了虚拟自述文件和其他文件,但是打算将它们放在gh-pages分支上。 If thats the case, the safest option is to merge your master branch into the gh-pages branch (assuming you dont have other files on master you would rather not have on the gh-pages branch). 如果是这种情况,最安全的选择是将您的主分支合并到gh-pages分支中(假设您没有其他文件在master上,您宁愿不在gh-pages分支上)。 The command suggested git push -f origin master:gh-pages will push your local master branch to the gh-pages branch. 命令建议git push -f origin master:gh-pages将你的本地主分支推送到gh-pages分支。 I'm not really sure what you mean but into vs onto, as branch names are just pointers in git. 我不太确定你的意思,但是对于vs,因为分支名称只是git中的指针。

Here is a good writeup github pages workflow that I used to understand how to interact between the master and gh-pages branches. 这是一个很好的写入github页面工作流 ,我用它来了解如何在master和gh-pages分支之间进行交互。

paul irish from google recommended it in the comments of another article- it had super clear examples. 来自谷歌的保罗爱尔兰人在另一篇文章的评论中推荐它 - 它有超级清晰的例子。

as an alternative approach, how about using a git subtree to serve as your gh-pages branch? 作为一种替代方法,如何使用git 子树作为你的gh-pages分支呢?

git checkout master
git subtree push --prefix . origin gh-pages

according to the git-subtree docs on the source code : 根据源代码上的git-subtree文档:

Subtrees allow subprojects to be included within a subdirectory of the main project, optionally including the subproject's entire history. 子项允许子项目包含在主项目的子目录中,可选地包括子项目的整个历史。

in our case, we may be able to alias the same path (the root path; . ) as a virtual copy of the master branch (i have not tested it, though). 在我们的例子中,我们可以将相同的路径(根路径; . )作为主分支的虚拟副本(我还没有测试过)。

by the way, i found out about subtrees after encountering this gist , by cobyism . 顺便说一句,我在遇到这个要点之后 ,通过cobyism找到了关于子树的信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM