Failed to deploy to Github Pages using octopress
Asked Answered
S

2

17

I have setup a setup a blog on github pages using Octopress. I have created my first post, and am able to view it on localhost using rake preview . However it is failing to deploy to github pages. Being new to git, am having trouble understanding the problem.

I run rake deploy to deploy to github pages, following their documentation.

I get this message:

## 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 [email protected]:slmnm/slmnm.github.io.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to '[email protected]: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 -

Following this question, I have set my branch.master.remote to origin. To resolve the non-fast-forward situation, I performed did git push origin master. After this, I was able to push code to github, but not deploy to github pages using rake deploy.

I am going to paste my git config file here, I don't know if this is going to help.

[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 = [email protected]:slmnm/slmnm.github.io.git
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
    remote = origin
    merge = refs/heads/master

As you may have guessed, I am doing this alone, and there are no collaborators (duh! blog). This is my repo. Please let me know if you need any other details. I am a git newb :) Thanks

Edit: I also got an email from github saying the following:

The page build failed with the following error:

A file was included in source/blog/archives/index.html that is a symlink or does not exist in your _includes directory.

This happened once, although I've tried deploying multiple times.

Sultan answered 25/1, 2014 at 21:1 Comment(0)
S
27

Ok. I have fixed the issue. So I am gonna answer this myself.

The problem I was facing is because I was trying to fix the issue from the octopress directory, when I should be doing so from _deploy directory.

Upon running rake deploy, octopress does cd _deploy and tries push updates to Github(in my case). During that time I was getting the message 'You asked me to pull without telling me which branch you ...'

After this, in the _deploy directory, I ran

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

git pull

This fixed both errors (one described above, and the non-fast forward error). Now push this to remote, ( or run rake deploy again ) .

This worked for me. If you have a better solution, I am open to changing the correct answer.

Sultan answered 27/1, 2014 at 2:9 Comment(1)
did not work for me :/ My solution was to first, very carefully back up my git repo. And then second, delete the master branch on github. Then I can push no problem with no conflicts (since it's a new branch).Orosco
S
9

This issue occurs when we have more than 1 branch and git is not able to recognize which branch to deploy.

In Rakefile, you can check what's the value of deploy_branch

deploy_branch = "master"  # For me its master

Then, down somewhere around line 250, there is a task named :push which gets called during rake deploy

In this :push task

after cd "#{deploy_dir}" do , git pull is done

Bundler.with_clean_env { system "git pull" }

In this command git is not able to recognize which branch to deploy, so we just need to change the above line as

Bundler.with_clean_env { system "git pull origin #{deploy_branch}" }
Sarsen answered 29/7, 2014 at 14:52 Comment(1)
This helped. I screwed up and pushed to my 'source' branch before I ran rake deploy. I tried 10 different things before this resolved my issue.Hatti

© 2022 - 2024 — McMap. All rights reserved.