Skip to content

v3: 'Removing files' step doesn't properly clean existing gh-pages content when repo contains submodules #204

@JohannesHoppe

Description

@JohannesHoppe

Description

When deploying to a gh-pages branch from a repository that uses git submodules, angular-cli-ghpages v3 fails to properly remove existing files from the gh-pages branch. This results in the deployed content containing files from the main branch (like .github/, .gitignore, .gitmodules, and the submodule gitlink) mixed with the intended dist content.

v2 works correctly - it properly removes all existing files before copying the new content.

Steps to Reproduce

  1. Create a repo with a git submodule (e.g., build/ pointing to another repo)
  2. Have an existing gh-pages branch with some content (or let the first deploy create it)
  3. Run angular-cli-ghpages v3 with --dir=dist where dist/ only contains your build output (e.g., blog/)

Expected Behavior

The gh-pages branch should only contain:

  • .nojekyll
  • Contents of dist/ (e.g., blog/)

Actual Behavior

The gh-pages branch contains:

  • .nojekyll
  • blog/
  • .github/ ✗ (from main branch)
  • .gitignore ✗ (from main branch)
  • .gitmodules ✗ (from main branch)
  • build ✗ (submodule gitlink, type "commit" in git tree)

Analysis

Looking at the deploy logs, the sequence is:

Cloning repo into cache...
Cleaning
Fetching origin
Checking out origin/gh-pages 
Removing files          <-- This step doesn't fully clean
Creating .nojekyll
Copying files
Adding all
Committing
Pushing

The "Removing files" step in v3 appears to not properly handle:

  1. Hidden files (.gitignore, .gitmodules)
  2. Hidden directories (.github/)
  3. Submodule gitlinks - In git, a submodule is stored as a "commit" type entry in the tree (not a regular file/directory). This might require special handling like git rm --cached or git submodule deinit.

Workaround

Use v2:

npm install angular-cli-ghpages@2
npx angular-cli-ghpages --dir=dist ...

Environment

Related

This might be related to changes in the bundling/packaging for v3, or changes in the underlying gh-pages npm package dependency.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions