2
votes

I'm trying to use Travis CI to build my Jekyll site and push to my gh-pages branch on Github. It's not working, I probably don't know what I'm doing.

The error is:
error: src refspec gh-pages does not match any.
error: failed to push some refs to 'https://github.com/jshwlkr/jshwlkr.info.git'

.travis.yml here: https://github.com/jshwlkr/jshwlkr.info/edit/master/.travis.yml

branches:
  only:
  - master
language: node_js
node_js:
- '6'
before_install:
- rvm install 2.2.3
- curl -o- -L https://yarnpkg.com/install.sh | bash
before_script:
- gem install bundler
- bundle install
- mkdir _site
- git clone https://[email protected]/jshwlkr/jshwlkr.info.git -v --branch gh-pages _site
- git status

after_success:
- cd _site
- git config user.email "[email protected]"
- git config user.name "jshwlkr"
- git add --all
- git status
- git commit -a -m "Travis #$TRAVIS_BUILD_NUMBER"
- git push --force origin gh-pages
- bundle exec rake webmention

last build here: https://travis-ci.org/jshwlkr/jshwlkr.info/builds/268142486

(I'm eventually going to either push to an additional server, or rsync. That's what those comments are.)

1

1 Answers

1
votes

Travis checks out a shallow clone, so your local copy on the build VM does not know about the gh-pages branch, which exists on GitHub. Try fetching the branch with

git fetch --unshallow

before running git push ….

Alternatively, you might want to try the GitHub Pages deployment provider. There are a couple of reported bugs, such as https://github.com/travis-ci/travis-ci/issues/7538 and https://github.com/travis-ci/travis-ci/issues/7562, but you might find it suitable for your needs.