Git.Remotes (git v0.4.0)

Copy Markdown View Source

Higher-level remote management helpers that compose lower-level Git functions.

Provides convenience functions for listing, adding, removing, and updating git remotes.

All functions accept an optional keyword list. Use :config to specify the repository via a Git.Config struct; when omitted a default config is built from the environment.

Summary

Functions

Lists remotes with their URLs.

Prunes stale remote-tracking branches for a remote.

Removes a remote.

Updates the URL of an existing remote.

Functions

add(name, url, opts \\ [])

@spec add(String.t(), String.t(), keyword()) :: {:ok, :done} | {:error, term()}

Adds a remote.

Uses Git.remote(add_name: name, add_url: url).

Returns {:ok, :done} on success.

list_detailed(opts \\ [])

@spec list_detailed(keyword()) :: {:ok, [Git.Remote.t()]} | {:error, term()}

Lists remotes with their URLs.

Delegates to Git.remote/1 which returns verbose output by default.

Returns {:ok, [Git.Remote.t()]}.

prune(name, opts \\ [])

@spec prune(
  String.t(),
  keyword()
) :: {:ok, :done} | {:error, term()}

Prunes stale remote-tracking branches for a remote.

Uses Git.fetch(remote: name, prune: true).

Returns {:ok, :done} on success.

remove(name, opts \\ [])

@spec remove(
  String.t(),
  keyword()
) :: {:ok, :done} | {:error, term()}

Removes a remote.

Uses Git.remote(remove: name).

Returns {:ok, :done} on success.

set_url(name, url, opts \\ [])

@spec set_url(String.t(), String.t(), keyword()) :: {:ok, :done} | {:error, term()}

Updates the URL of an existing remote.

Uses git remote set-url via raw System.cmd since the command module does not expose a set-url option.

Returns {:ok, :done} on success.