文章目录
  1. 1. 方法一
  2. 2. 方法二

今天尝试往 github 上导 octopress,发现了下面的问题:

1
2
3
4
5
6
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/xxx/xxx.github.io'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

看了很多地方,发现下面两种解决方法:

方法一

在执行 rake deploy 之后,octpress 会执行 cd _deploy 命令,进入 _deploy 目录,并且尝试向Github提交更新。也就是说,需要在 _deploy 目录下进行一些设置。

我的做法是,进入 _deploy 目录,执行:

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

git pull

这样就解决了 no-fast forward 这个错误了,然后就可以把更新提交到 Github,或者重新执行 rake deploy

方法二

修改 octopress 下的 Rakefile,那下面的内容:

1
system "git push origin #{deploy_branch}"

改成

1
system "git push origin +#{deploy_branch}"

就OK了。


个人认为,方法二比较靠谱,一劳永逸。

文章目录
  1. 1. 方法一
  2. 2. 方法二