Class: Git::Commands::Branch::SetUpstream Private

Inherits:
Git::Commands::Base show all
Defined in:
lib/git/commands/branch/set_upstream.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-branch/2.53.0

Implements the git branch --set-upstream-to command for configuring upstream tracking

This command sets up tracking information so the specified upstream branch is considered the upstream for the given branch (or current branch if not specified).

Examples:

Set upstream for current branch

set_upstream = Git::Commands::Branch::SetUpstream.new(execution_context)
set_upstream.call(set_upstream_to: 'origin/main')

Set upstream for a specific branch

set_upstream = Git::Commands::Branch::SetUpstream.new(execution_context)
set_upstream.call('feature', set_upstream_to: 'origin/main')

See Also:

Instance Method Summary collapse

Methods inherited from Git::Commands::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(**options) ⇒ Git::CommandLineResult #call(branch_name, **options) ⇒ Git::CommandLineResult

Execute the git branch --set-upstream-to command

Overloads:

  • #call(**options) ⇒ Git::CommandLineResult

    Sets upstream for the current branch

    Parameters:

    • options (Hash)

      command options

    Options Hash (**options):

    • :set_upstream_to (String) — default: required

      the upstream branch (e.g., 'origin/main')

      Alias: :u

    Returns:

    Raises:

    • (ArgumentError)

      if set_upstream_to is not provided

    • (ArgumentError)

      if unsupported options are provided

    • (Git::FailedError)

      if git exits with a non-zero exit status

  • #call(branch_name, **options) ⇒ Git::CommandLineResult

    Set upstream for the specified branch

    Parameters:

    • branch_name (String)

      the branch to set upstream for

    • options (Hash)

      command options

    Options Hash (**options):

    • :set_upstream_to (String) — default: required

      the upstream branch (e.g., 'origin/main')

      Alias: :u

    Returns:

    Raises:

    • (ArgumentError)

      if set_upstream_to is not provided

    • (ArgumentError)

      if unsupported options are provided

    • (Git::FailedError)

      if git exits with a non-zero exit status



# File 'lib/git/commands/branch/set_upstream.rb', line 42