# `Git.Worktree`
[🔗](https://github.com/joshrotenberg/git_wrapper_ex/blob/main/lib/git/worktree.ex#L1)

Parsed representation of a git worktree entry.

Contains the path, HEAD commit SHA, branch reference, and flags
indicating whether the worktree is bare or has a detached HEAD.

# `t`

```elixir
@type t() :: %Git.Worktree{
  bare: boolean(),
  branch: String.t() | nil,
  detached: boolean(),
  head: String.t(),
  path: String.t()
}
```

# `parse`

```elixir
@spec parse(String.t()) :: [t()]
```

Parses the porcelain output of `git worktree list --porcelain` into a list
of `Git.Worktree` structs.

The porcelain format separates entries with blank lines. Each entry has
key-value lines like:

    worktree /path/to/main
    HEAD abc1234
    branch refs/heads/main

## Examples

    iex> Git.Worktree.parse("worktree /tmp/main\nHEAD abc1234\nbranch refs/heads/main\n\n")
    [%Git.Worktree{path: "/tmp/main", head: "abc1234", branch: "refs/heads/main", bare: false, detached: false}]

    iex> Git.Worktree.parse("")
    []

---

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