angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

Unable to deploy organization to github pages with --user-page flag

Open johnazre opened this issue 10 years ago • 4 comments

Please provide us with the following information:

OS?

Mac OSX (Sierra)

Versions.

angular-cli: 1.0.0-beta.19-3 node: 6.6.0 os: darwin x64

Repro steps.

In this order:

  • Created project with ng new newProject
  • Created repo on github
  • Added ssh remote origin on the command line
  • Pushed project to github
  • Tried ng github-pages:deploy. The build seemed to work, but then I got the error below.

The log given by the failure.

Error: Command failed: git push origin gh-pages:master
To [email protected]:something/something.github.io.git
 ! [rejected]        gh-pages -> master (non-fast-forward)
error: failed to push some refs to '[email protected]:something/something.github.io.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

at ChildProcess.exithandler (child_process.js:206:12)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:877:16)
at Socket.<anonymous> (internal/child_process.js:334:11)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at Pipe._handle.close [as _onclose] (net.js:493:12)

When I try to pull, it says everything is up to date.

I am able to make it work by manually merging gh-pages into master, then add/commit/push that to Github.

johnazre avatar Nov 06 '16 21:11 johnazre

This is actually a rather unfortunate case... the way ng github-pages:deploy works is by making a new branch with only the contents of the dist/ directory.

Usually that branch is pushed up to gh-pages, a new remote branch. All is fine in that case. But on user and org pages, you have to push to master. And master is where your app code lives already... so when we push, there's a git error. You can't have both the built site and your project at the same time there.

So my recommendation is that you have your project proper in another branch that isn't master, for instance a new one called app.

I'd like to find a better way of doing this if there's one.

filipesilva avatar Nov 16 '16 18:11 filipesilva

What about using a temp directory outside of the current project? This would allow use of the master branch as it would be a separate repo.

This could be a system temp directory or simply up one directory from the project. Maybe the directory name includes a unique timestamp integer?

For future updates, the existing remote github pages repo would be cloned into the temp directory first before the new dist files are copied, then pushed back.

As implied with temp, the directory would be deleted after deployment.

Thoughts?

rolyatsats avatar Dec 10 '16 17:12 rolyatsats

Closed via https://github.com/angular/angular-cli/pull/4385.

filipesilva avatar Feb 03 '17 14:02 filipesilva

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.