# How to create a GitHub gh-pages branch in an existing repository

This blog post is a really short one.

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1638031326558/PGNIGxxD5.png)

Recently I wanted GitHub to serve my Helm chart via GitHub pages. So far so good, but I had already committed to the main branch. And I wanted a clean branch for my Helm repository.

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1638032311134/rfha7kFTT.png)

But with a little Git magic it is possible to get a clean branch. Let me show you, what I did:

## Checkout an orphan gh-pages branch

An orphan branch has no parents, means no git history when it is created. The history of the orphan branch is separate from other branches in the repository.

```
git checkout --orphan gh-pages
git reset --hard
git commit --allow-empty -m "fresh and empty gh-pages branch"
git push origin gh-pages
```

## Activate GitHub Pages

After pushing the branch to GitHub, we can head over to the `Settings page` of the repository and select in the `GitHub Pages` section the `gh-pages`branch as source.

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1638032241182/uVIWziwi5.png)

You should be able to access it via `https://your-username.github.io/<repository-name>/`
