# `HfHub.Git`
[🔗](https://github.com/North-Shore-AI/hf_hub_ex/blob/v0.3.1/lib/hf_hub/git.ex#L1)

Git operations for HuggingFace Hub repositories.

Provides branch, tag, and commit management.

## Examples

    # Create a branch
    {:ok, info} = HfHub.Git.create_branch("my-org/my-model", "feature-branch")

    # Create a tag with a message
    {:ok, info} = HfHub.Git.create_tag("my-model", "v1.0", message: "Release v1.0")

    # List all refs
    {:ok, refs} = HfHub.Git.list_refs("bert-base-uncased")

    # List commits
    {:ok, commits} = HfHub.Git.list_commits("bert-base-uncased")

    # Super squash (destructive)
    :ok = HfHub.Git.super_squash("my-model", message: "Squashed history")

# `repo_type`

```elixir
@type repo_type() :: :model | :dataset | :space
```

# `create_branch`

```elixir
@spec create_branch(String.t(), String.t(), keyword()) ::
  {:ok, HfHub.Git.BranchInfo.t()} | {:error, term()}
```

Creates a new branch in a repository.

## Options

  * `:token` - Authentication token
  * `:repo_type` - Repository type (:model, :dataset, :space). Defaults to :model.
  * `:revision` - Source revision to branch from. Defaults to "main".
  * `:exist_ok` - Don't error if branch exists. Defaults to false.

## Examples

    {:ok, info} = HfHub.Git.create_branch("my-model", "feature-branch")
    {:ok, info} = HfHub.Git.create_branch("my-model", "hotfix", revision: "v1.0")
    {:ok, info} = HfHub.Git.create_branch("my-model", "dev", exist_ok: true)

# `create_tag`

```elixir
@spec create_tag(String.t(), String.t(), keyword()) ::
  {:ok, HfHub.Git.TagInfo.t()} | {:error, term()}
```

Creates a new tag in a repository.

## Options

  * `:token` - Authentication token
  * `:repo_type` - Repository type. Defaults to :model.
  * `:revision` - Revision to tag. Defaults to "main".
  * `:message` - Optional tag message (creates annotated tag).
  * `:exist_ok` - Don't error if tag exists. Defaults to false.

## Examples

    {:ok, info} = HfHub.Git.create_tag("my-model", "v1.0")
    {:ok, info} = HfHub.Git.create_tag("my-model", "v2.0",
      revision: "abc123", message: "Release v2.0")

# `delete_branch`

```elixir
@spec delete_branch(String.t(), String.t(), keyword()) :: :ok | {:error, term()}
```

Deletes a branch from a repository.

## Options

  * `:token` - Authentication token
  * `:repo_type` - Repository type. Defaults to :model.

## Examples

    :ok = HfHub.Git.delete_branch("my-model", "old-branch")

# `delete_tag`

```elixir
@spec delete_tag(String.t(), String.t(), keyword()) :: :ok | {:error, term()}
```

Deletes a tag from a repository.

## Options

  * `:token` - Authentication token
  * `:repo_type` - Repository type. Defaults to :model.

## Examples

    :ok = HfHub.Git.delete_tag("my-model", "old-tag")

# `list_commits`

```elixir
@spec list_commits(
  String.t(),
  keyword()
) :: {:ok, [HfHub.Git.CommitInfo.t()]} | {:error, term()}
```

Lists commits in a repository.

## Options

  * `:token` - Authentication token
  * `:repo_type` - Repository type. Defaults to :model.
  * `:revision` - Branch/tag/commit to list from. Defaults to "main".

## Examples

    {:ok, commits} = HfHub.Git.list_commits("bert-base-uncased")
    Enum.take(commits, 10)  # First 10 commits

# `list_refs`

```elixir
@spec list_refs(
  String.t(),
  keyword()
) :: {:ok, HfHub.Git.GitRefs.t()} | {:error, term()}
```

Lists all refs (branches, tags) in a repository.

## Options

  * `:token` - Authentication token
  * `:repo_type` - Repository type. Defaults to :model.
  * `:include_pull_requests` - Include PR refs. Defaults to false.

## Examples

    {:ok, refs} = HfHub.Git.list_refs("bert-base-uncased")
    refs.branches  # [%BranchInfo{name: "main", ...}]
    refs.tags      # [%TagInfo{name: "v1.0", ...}]

# `super_squash`

```elixir
@spec super_squash(
  String.t(),
  keyword()
) :: :ok | {:error, term()}
```

Squashes all commits into a single commit.

WARNING: This is a destructive operation. Use with caution.

## Options

  * `:token` - Authentication token (required)
  * `:repo_type` - Repository type. Defaults to :model.
  * `:branch` - Branch to squash. Defaults to "main".
  * `:message` - Commit message for squashed commit.

## Examples

    :ok = HfHub.Git.super_squash("my-model", message: "Squashed history")

---

*Consult [api-reference.md](api-reference.md) for complete listing*
