Octopress将错误推送到GitHub

16
我正在尝试将 Octopress 推送到 GitHub 页面,到目前为止一切都很顺利,但当我在显示 Octopress 文件后执行 rake deploy 命令时,出现以下错误。
To git@github.com:rukshn/rukshn.github.io.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'git@github.com:rukshn/rukshn.github.io.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

有什么问题吗?


1
@SLaks,有什么问题,怎么解决? - rksh
从 Octopress Rakefile 的代码来看,它应该在推送之前拉取任何更改,但似乎并没有发生这种情况。 正如错误消息所暗示的,您是否尝试先运行 git pull 呢? - james246
我先执行了一次 pull,然后再次执行了 'rake deploy',但是仍然出现了相同的错误。所以我又执行了一次 pull,结果显示所有内容都是最新的。 - rksh
我刚刚删除了master分支,然后再次运行了rake deploy - onmyway133
5个回答

31

由于这是主分支,即运行生成页面的分支,您需要进入_deploy目录,然后执行git pull origin master。您的部署目录似乎已经失去同步了。您是否有多个本地仓库用于编写和部署?(比如在不同的机器上...)如果有,那么您应该始终确保在各个仓库上同步源代码。


不确定我是怎么搞砸了主分支,但这个修复了它,谢谢! - scape
您IP地址为143.198.54.68,由于运营成本限制,当前对于免费用户的使用频率限制为每个IP每72小时10次对话,如需解除限制,请点击左下角设置图标按钮(手机用户先点击左上角菜单按钮)。 - slashmili

13

cd _deploy
git reset --hard origin/master
cd ..

请重试

rake generate
rake deploy

1
尝试一下:

git checkout source

rake gen_deploy


(注:该文本为HTML代码,已保留原样)

仍然收到相同的错误信息,Octopress 未被推送到 GitHub。 - rksh

0

我遇到了问题,并通过在源分支的_deploy文件夹中删除主分支来解决它。具体命令如下:

// change directory to _deploy
cd _deploy                             

// check out local master branch
git checkout master                    

// rename local master to master2
git branch -m master2                  

// list of remote branch
git branch -r                          

// create a new local master branch and tracking remote master branch
git checkout origin/master -b master   

// pull the remote master branch, ensure that the local master branch has Already up-to-date.
git pull                               

// delete the local master2 branch if not needed.
git branch -d master2                  

```


0

别忘了提交你的博客源代码。

  1. git add .
  2. git commit -m '将源代码添加到源分支'
  3. git push origin source

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接