0

I'm having trouble pushing to my gh-pages branch.

I have an organization account, with both server and client code in it (though I think this should not really matter). So the structure is like so:

my-org
   my-repo
      client
         src
      server
         src

This is how I am reproducing the issue:

  • create a new directory on my machine, just to be sure everything is clean
  • clone the repo into it
  • build the static angular app - this creates a directory /client/dist

My directory now contains this:

my-repo
   client
      src
      dist <-- this is what I want to go into gh-pages branch
   server
      src

The files in this directory are want to serve via github pages. So I run

git subtree push --prefix client/dist origin gh-pages

This however outputs:

git subtree push --prefix client/dist origin gh-pages
git push using:  origin gh-pages
To github.com:my-org/my-repo.git
 ! [rejected]        c7ac6936acbe0f5751755d60776074b98dae54d6 -> gh-pages (non-fast-forward)
error: failed to push some refs to 'git@github.com:my-repo/my-repo.git'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. Check out this branch and integrate the remote changes
hint: (e.g. 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

I really don't understand this message (how can anything be behing its remote counterpart in this situation?), and also following the advice (git pull) does nothing,

git pull on master and on gh-pages returns the expected:

Already up-to-date.

What am I missing? (I'm on git version 2.10.1)

Hoff
  • 38,776
  • 17
  • 74
  • 99
  • What info does `gitk --all` provide? Do you see `origin/gh-pages` and `gh-pages` in two different locations? Is `dist/` in your `.gitignore` file? – J. Titus Mar 07 '17 at 21:23
  • dist/ is not in .gitignore, and there is only one gh-pages/remotes/origin/gh-pages - but it looks a bit strange, I will have a look it, thanks for pointing me to gitk! – Hoff Mar 07 '17 at 21:32

1 Answers1

0

If the only purpose of the gh-pages branch is to build what's in your repo, just delete gh-pages branch from github completely and then run the subtree push command

Kyle Burkett
  • 1,375
  • 12
  • 28