How to deploy subfolder to Github Pages

August 7, 2020
zemna@zemna.net

We can use git subtree to do this. And also nest git commands to execute force push (Reference).

git push origin `git subtree split --prefix subfolder-name-here master`:gh-pages --force

Put this command to package.json file like bellow.

{
    "name": "My App",
    "dependencies": { ... },
    "scripts": {
        "deploy": "git push origin `git subtree split --prefix subfolder-name-here master`:gh-pages --force"
    }
}

After that, we can use npm run deploy command to deploy subfolder to gh-pages branch.

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram