# Git repository

> For AI agents: the complete documentation index is at https://buddy.works/llms.txt

Host a private Git repository as a Buddy artifact at git.buddy.works. Clone and push over HTTPS or SSH; each branch and tag becomes an artifact version.

A Git Repository artifact is a private Git repository hosted in Buddy at `git.buddy.works`. You clone it and push changes with a regular `git` client, and each branch and tag shows up in Buddy as an artifact version.

## Repository URLs

The address contains only the workspace and the artifact identifier, without the project name:

```
https://git.buddy.works/my-workspace/my-repo
ssh://buddy@git.buddy.works:2222/my-workspace/my-repo
```

## Artifact creation

In **Artifacts**, click **New artifact** and select **Git Repository**. In an empty repository, the **Code** tab shows the **Empty repository** message and the clone addresses. Later, the **Clone repository** window shows the same addresses.

![Clone repository window of a Git Repository artifact](https://buddy.works/docs/artifacts/git-repository-clone.png)

The artifact view has the **Code**, **Commits**, **Branches**, **Tags**, **Permissions** and **Settings** tabs.

## Repository authentication

You can clone the repository in three ways:

- **SSH** - authentication using an SSH key configured in **Manage Git SSH keys**, with the repository URL `ssh://buddy@git.buddy.works:2222/my-workspace/my-repo`
- **HTTPS with a password** - authentication using the account email address as the username and the password configured in **Manage password**
- **HTTPS with a token** - authentication using a [personal access token](https://buddy.works/docs/api/getting-started/oauth2/personal-access-token.md) included in the repository URL

A token does not require typing a password, so it works in scripts and third-party CI. The first push to an empty repository:

```bash
git clone "https://${REGISTRY_TOKEN}@git.buddy.works/my-workspace/my-repo"
cd my-repo
git checkout -b main
echo "# my-repo" > README.md
git add . && git commit -m "Initial commit"
git push -u origin main
```

The `You appear to have cloned an empty repository` warning is expected when cloning an empty repository. If HTTPS credentials are not provided, Git prompts for authentication. In non-interactive environments, such as pipeline actions, this may result in the `could not read Username for 'https://git.buddy.works'` error.

## Branches and tags as artifact versions

Each pushed branch and tag is a separate artifact version named after the full ref:

| Command | Artifact version |
| :--- | :--- |
| `git push -u origin main` | `refs/heads/main` |
| `git push origin v1.0.0` | `refs/tags/v1.0.0` |
| `git push origin --delete feature/login` | the branch version is deleted |

You cannot give a version an arbitrary name. The API rejects a name without a ref prefix, for example `v1`, with the message `Version must start with refs/heads/ or refs/tags/`.

![Tags tab of a Git Repository artifact](https://buddy.works/docs/artifacts/git-repository-tags.png)

You can also create commits without a `git` client, through the [artifact commits API](https://buddy.works/docs/api/artifacts/versions/commits.md).

## Access control and permissions

For this type, the **Access control** field in **Settings** has the **Buddy Auth** and **Public** options. You set pipeline and sandbox permissions in the **Permissions** tab, described in [Permissions and access](https://buddy.works/docs/artifacts/permissions-and-access.md).

See also:

- [Versions](https://buddy.works/docs/artifacts/versions.md) - version names and the run history of a version
- [Scopes](https://buddy.works/docs/artifacts/scopes.md) - Workspace, Project and Environment scope
- [Access control](https://buddy.works/docs/artifacts/access-control.md) - Buddy Auth and public access
- [Personal access tokens](https://buddy.works/docs/api/getting-started/oauth2/personal-access-token.md) - creating a token for cloning and pushing


---
Original source: https://buddy.works/docs/artifacts/git-repository