未能使用octopress部署到gizub页面

内容来源于 Stack Overflow,并遵循CC BY-SA 3.0许可协议进行翻译与使用

  • 回答 (2)
  • 关注 (0)
  • 查看 (22)

我运行rake deploy若要部署到GitHub页面,

我收到这样的信息:

## 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 -

我把我的branch.master.remoteorigin。为了解决非快进的情况,我做了git push origin master...。在此之后,我能够将代码推送到GitHub,但不能使用以下方法部署到GitHub页面rake deploy

[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
提问于
用户回答回答于

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

我所面临的问题是因为我试图从octopress目录修复这个问题,而我应该从_部署目录。

在运行时rake deploy cd _deploy并尝试将更新推送到Gizub(在我的例子中)。在这段时间里我收到了这条信息You asked me to pull without telling me which branch you ...

在这之后,在_部署目录,我运行

git config branch.master.remote origin
git config branch.master.merge refs/heads/master

git pull

这修复了两个错误(上面描述的一个错误,以及非快速转发错误)。现在将其推送到远程(或运行)rake deploy(再一次)。

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

用户回答回答于

这个问题发生在我们有超过一个分支并且git无法识别要部署的分支。

在Rakefile中,可以检查deploy_branch

deploy_branch = "master"  # For me its master

然后,在第250行的某个地方,有一个名为:Push的任务,它将在rake deploy

在这里:push任务

cd "#{deploy_dir}" do,Git拉力完成

Bundler.with_clean_env { system "git pull" }

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

Bundler.with_clean_env { system "git pull origin #{deploy_branch}" }

扫码关注云+社区