Class: Git::Commands::Remote::SetBranches Private

Inherits:
Base
  • Object
show all
Defined in:
lib/git/commands/remote/set_branches.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Note:

arguments block audited against https://git-scm.com/docs/git-remote/2.53.0

git remote set-branches command

Changes the list of branches tracked for the named remote. This can be used to track a subset of the available remote branches after the initial setup.

Examples:

Set the tracked branches for a remote

set_branches = Git::Commands::Remote::SetBranches.new(execution_context)
set_branches.call('origin', 'main', 'develop')

Append additional tracked branches without replacing existing ones

set_branches = Git::Commands::Remote::SetBranches.new(execution_context)
set_branches.call('origin', 'release/*', add: true)

See Also:

Instance Method Summary collapse

Methods inherited from Base

allow_exit_status, arguments, #initialize, requires_git_version, skip_version_validation

Constructor Details

This class inherits a constructor from Git::Commands::Base

Instance Method Details

#call(name, *branch, **options) ⇒ Git::CommandLineResult

Execute the git remote set-branches command

Parameters:

  • name (String)

    the remote name to update

  • branch (Array<String>)

    one or more branch names or glob patterns to track

  • options (Hash)

    command options

Options Hash (**options):

  • :add (Boolean, nil) — default: nil

    append the given branches instead of replacing them

Returns:

Raises:

  • (ArgumentError)

    if unsupported options are provided

  • (Git::FailedError)

    if git exits with a non-zero exit status



# File 'lib/git/commands/remote/set_branches.rb', line 41