error deploying static webpage build with nanoc on github with orphan git branch

53 Views Asked by At

I followed this tutorial on the nanoc webpage to deploy my webpage on github. I followed these instructions

% rm -rf output
% git clone . output
% cd output
output@master% git checkout --orphan gh-pages
output@gh-pages% git rm -rf 
output@gh-pages% git remote rm origin
output@gh-pages% git remote add origin repo-url

but when i want to run

nanoc 
nanoc deploy 

i need to change in the base directory where the nanoc.yaml file is. But when switching i also change back(?) to the main branch from the gh-pages branch. I suppose that is because of the orphan nature of the branch, but this is just wildly guessing.

and nanoc terminates with this error message

Loading site… done                   
Deploying via Git to branch “gh_pages” on remote “origin”…                 
[email protected]:name/repo_name.git                              
error: pathspec 'gh_pages' did not match any file(s) known to git.         

Captain! We’ve been hit!             

Message:                             

Nanoc::Deploying::Deployers::Git::Errors::BranchDoesNotExist: The branch to deploy, gh_pages, does not exist.                                         

This is the relevant part of the nanoc.yaml file. (the rest is the unchanged standard)

deploy:                          
  default:                       
    kind: git
    remote: [email protected]:name/repo_name.git
    branch: gh_pages

Hope someone can tell me where my ship has been hit and how i can avoid this ice rock ;)

2

There are 2 best solutions below

0
On

The error message was acutally quite clear:

The branch to deploy, gh_pages, does not exist.

On github i did not have the orphan branch. So after creating the branch in the output folder i pushed this branch i was able to use ´nanoc´ and ´nanoc deploy´ to automatically deploy the page.

1
On

You have a typo in the branch name in the Nanoc configuration. Change

branch: gh_pages

to

branch: gh-pages

(replace the underscore by a hypen) and the deploy should succeed.