首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >无法使用octopress部署到Github页面

无法使用octopress部署到Github页面
EN

Stack Overflow用户
提问于 2014-01-26 05:01:54
回答 2查看 3K关注 0票数 17

我已经用Octopress在github页面上设置了一个博客。我已经创建了我的第一篇文章,并且能够使用rake preview在本地主机上查看它。然而,它未能部署到github页面。作为git的新手,我很难理解这个问题。

我根据它们的documentation运行rake deploy来部署到github页面。

我得到了这样的信息:

代码语言:javascript
复制
## Deploying branch to Github Pages 
## Pulling any updates from Github Pages 
cd _deploy
You asked me to pull without telling me which branch you
want to merge with, and 'branch.master.merge' in
your configuration file does not tell me, either. Please
specify which branch you want to use on the command line and
try again (e.g. 'git pull <repository> <refspec>').
See git-pull(1) for details.

If you often merge with the same branch, you may want to
use something like the following in your configuration file:
    [branch "master"]
    remote = <nickname>
    merge = <remote-ref>

    [remote "<nickname>"]
    url = <url>
    fetch = <refspec>

See git-config(1) for details.
cd -
rm -rf _deploy/blog
rm -rf _deploy/robots.txt
rm -rf _deploy/javascripts
rm -rf _deploy/stylesheets
rm -rf _deploy/sitemap.xml
rm -rf _deploy/favicon.png
rm -rf _deploy/atom.xml
rm -rf _deploy/index.html
rm -rf _deploy/images
rm -rf _deploy/assets

## Copying public to _deploy
cp -r public/. _deploy
cd _deploy

## Committing: Site updated at 2014-01-25 20:13:51 UTC
# On branch master
nothing to commit (working directory clean)

## Pushing generated _deploy website
To git@github.com:slmnm/slmnm.github.io.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'git@github.com:slmnm/slmnm.github.io.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again.  See the
'Note about fast-forwards' section of 'git push --help' for details.

## Github Pages deploy complete
cd -

this question之后,我将我的branch.master.remote设置为origin。为了解决非快进的情况,我执行了did git push origin master。在此之后,我可以将代码推送到github,但不能使用rake deploy部署到github页面。

我打算在这里粘贴我的git配置文件,我不知道这是否会有帮助。

代码语言:javascript
复制
[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
[remote "octopress"]
    url = git://github.com/imathis/octopress.git
    fetch = +refs/heads/*:refs/remotes/octopress/*
[branch "source"]
    remote = origin
    merge = refs/heads/master
[remote "origin"]
    url = git@github.com:slmnm/slmnm.github.io.git
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
    remote = origin
    merge = refs/heads/master

正如你可能已经猜到的,我是一个人在做这件事,并且没有合作者(嗯!博客)。这是我的repo。如果您需要任何其他细节,请让我知道。我是个git newb :)谢谢

编辑:我还收到了一封来自github的电子邮件,内容如下:

页面生成失败,出现以下错误:

source/blog/archives/index.html中包含的文件是符号链接或在您的_includes目录中不存在。

这种情况只发生过一次,尽管我已经尝试过多次部署。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-01-27 10:09:04

好的。我已经解决了这个问题。所以我要亲自回答这个问题。

我面临的问题是因为我试图从octopress目录解决这个问题,而我应该从_deploy目录这样做。

在运行rake deploy时,octopress执行cd _deploy并尝试将更新推送到Github(在我的例子中)。在那段时间里,我收到了一条消息'You asked me to pull without telling me which branch you ...

在此之后,在_deploy目录中,我运行

代码语言:javascript
复制
git config branch.master.remote origin
git config branch.master.merge refs/heads/master

git pull

这修复了两个错误(一个如上所述,以及非快进错误)。现在将其推送到remote (或再次运行rake deploy )。

这对我很有效。如果你有更好的解决方案,我愿意改变正确的答案。

票数 27
EN

Stack Overflow用户

发布于 2014-07-29 22:52:48

当我们有超过1个分支,而git无法识别要部署哪个分支时,就会出现此问题。

在Rakefile中,您可以查看deploy_branch的值是什么

代码语言:javascript
复制
deploy_branch = "master"  # For me its master

然后,在第250行附近的某个位置,有一个名为:push的任务,它在rake deploy期间被调用

在此:push任务中

cd "#{deploy_dir}" do之后,git拉取完成

代码语言:javascript
复制
Bundler.with_clean_env { system "git pull" }

在此命令中,git无法识别要部署的分支,因此我们只需将上一行更改为

代码语言:javascript
复制
Bundler.with_clean_env { system "git pull origin #{deploy_branch}" }
票数 9
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21356212

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档