%%
date:: [[2023-05-06]]
parent:: [[GitHub]], [[GitHub Pages]], [[Git]], [[Subtrees in Git]]
%%
# [[Deploying a subfolder to GitHub Pages]]
[[GitHub Pages]] lets you publish the `gh-pages` branch of a repository. Here's how to add only a subfolder of your main branch to the `gh-pages` branch.
`git add path/to/subfolder && git commit -m 'Initial commit'`
`git subtree push --prefix path/to/subfolder origin gh-pages`
These commands create a `gh-pages` branch and add only files from the `path/to/subfolder` to the new branch, so that only that branch is published.
Simply [[Branching in Git#^1b2f9b|creating and checking out a branch]] would just copy the entire main branch to the new branch, and the `git subtree push` command makes sure only the subfolder is copied over.