# Using Git for a Helm Chart Repo


Git Repos can be used to store Helm Charts, and can be imported by the Helm CLI to install charts to your Kubernetes cluster. My repo of charts for this example can be found [here](https://github.com/jmarhee/charts/tree/main).

Assume you create a repo with the following structure, a repo named `charts`:

```yaml
 ~/repos/charts (main) $ ls
assets      charts  
```

where `charts` subdirectory contains all of your Helm chart templates like you might normally normally expect, and `assets` where you are going to store the Helm `tar.gz` packages we will create that the Helm CLI will actually pull and install.

In my case, my repo contains the following charts:

```yaml
~/repos/charts (main) $ ls charts
sysdepot-authoritative-dns  sysdepot-logging
sysdepot-bitbucket      sysdepot-postgres
```

and I want to publish a chart for `sysdepot-logging`, so I will package it:

```yaml
helm package charts/sysdepot-logging -d assets/sysdepot-logging
Successfully packaged chart and saved it to: charts/assets/sysdepot-logging-0.1.0.tgz
```

but before committing this archive and use my Git repo with Helm, I have to create an index so Helm can actually know where in my Git repo to find the chart bundle:

```yaml
helm repo index .
```

which creates an `index.yaml` file:

```yaml
apiVersion: v1
entries:
  sysdepot-logging:
  - apiVersion: v2
    appVersion: 1.16.0
    created: "2024-05-09T10:08:39.866741-05:00"
    description: A Helm chart for Kubernetes
    digest: ac545bd91ad481795556a331b15bd4871e598d1e89d0c54ed338ab9afb2b8771
    name: sysdepot-logging
    type: application
    urls:
    - assets/sysdepot-logging-0.1.0.tgz
    version: 0.1.0
generated: "2024-05-09T10:08:39.866166-05:00"
```

in the root of my repo that points to the archive in my assets directory.

So, with that created, I commit my charts, and the archives, and the index file to my git repo as I would with any git repository (`git add`, `commit`, etc.)

For a Github repo, for example, you can add it to Helm using the following format:

```yaml
helm repo add jmarhee https://raw.githubusercontent.com/{your_username}/{your_repo}/{target_branch}/
```

then after `helm repo update`, you can install charts from your new repo.
