# `Git.Commands.Push`
[🔗](https://github.com/joshrotenberg/git_wrapper_ex/blob/main/lib/git/commands/push.ex#L1)

Implements the `Git.Command` behaviour for `git push`.

Supports pushing to a remote with options for force push, upstream tracking,
tags, delete, dry run, and more.

# `t`

```elixir
@type t() :: %Git.Commands.Push{
  all: boolean(),
  atomic: boolean(),
  branch: String.t() | nil,
  delete: boolean(),
  dry_run: boolean(),
  force: boolean(),
  force_with_lease: boolean(),
  no_verify: boolean(),
  prune: boolean(),
  remote: String.t() | nil,
  set_upstream: boolean(),
  tags: boolean()
}
```

# `args`

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

Returns the argument list for `git push`.

Builds the argument list from the struct fields. Boolean flags are appended
when set to `true`. The `remote` and `branch` positional arguments are
appended at the end when present.

## Examples

    iex> Git.Commands.Push.args(%Git.Commands.Push{})
    ["push"]

    iex> Git.Commands.Push.args(%Git.Commands.Push{remote: "origin", branch: "main"})
    ["push", "origin", "main"]

    iex> Git.Commands.Push.args(%Git.Commands.Push{remote: "origin", set_upstream: true, branch: "feature"})
    ["push", "-u", "origin", "feature"]

    iex> Git.Commands.Push.args(%Git.Commands.Push{force: true, tags: true})
    ["push", "--force", "--tags"]

# `parse_output`

```elixir
@spec parse_output(String.t(), non_neg_integer()) ::
  {:ok, :done} | {:error, {String.t(), non_neg_integer()}}
```

Parses the output of `git push`.

On success (exit code 0), returns `{:ok, :done}`. On failure, returns
`{:error, {stdout, exit_code}}`.

---

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