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

Parsed representation of a git branch entry.

Contains the branch name, whether it is the currently checked-out branch,
whether it is a remote-tracking branch, its upstream tracking reference,
and the ahead/behind commit counts relative to the upstream.

# `t`

```elixir
@type t() :: %Git.Branch{
  ahead: non_neg_integer(),
  behind: non_neg_integer(),
  current: boolean(),
  name: String.t(),
  remote: boolean(),
  upstream: String.t() | nil,
  worktree: boolean()
}
```

# `parse`

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

Parses the output of `git branch -vv` into a list of `Git.Branch` structs.

Each line has the form:

    * main                abc1234 [origin/main: ahead 1] subject
      feature/foo         def5678 [origin/feature/foo] subject
      remotes/origin/HEAD -> origin/main

Lines beginning with `remotes/` are remote-tracking refs. Lines containing
` -> ` are symbolic refs (e.g. `HEAD -> main`) and are skipped.

## Examples

    iex> Git.Branch.parse("* main abc1234 subject\n")
    [%Git.Branch{name: "main", current: true, remote: false}]

---

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