Class: Git::Commands::Remote::SetHead Private

Inherits:
Base
  • Object
show all
Defined in:
lib/git/commands/remote/set_head.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-head command

Sets or deletes the default branch (symbolic HEAD) for the named remote.

Examples:

Set the remote HEAD to a specific branch

set_head = Git::Commands::Remote::SetHead.new(execution_context)
set_head.call('origin', 'main')

Auto-detect the remote HEAD by querying the remote

set_head = Git::Commands::Remote::SetHead.new(execution_context)
set_head.call('origin', auto: true)

Delete the remote HEAD symbolic ref

set_head = Git::Commands::Remote::SetHead.new(execution_context)
set_head.call('origin', delete: 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) ⇒ Git::CommandLineResult #call(name, **options) ⇒ Git::CommandLineResult

Overloads:

  • #call(name, branch) ⇒ Git::CommandLineResult

    Set the remote's HEAD symbolic ref to a specific branch

    Parameters:

    • name (String)

      the remote name to update

    • branch (String)

      the branch to set as the remote HEAD

    Returns:

    Raises:

    • (ArgumentError)

      if unsupported options are provided

    • (Git::FailedError)

      if git exits with a non-zero exit status

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

    Detect or delete the remote's HEAD symbolic ref

    Parameters:

    • name (String)

      the remote name to update

    • options (Hash)

      command options

    Options Hash (**options):

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

      detect the remote HEAD by querying the remote

      Mutually exclusive with :delete. Alias: :a

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

      delete the configured remote HEAD symbolic ref

      Mutually exclusive with :auto. Alias: :d

    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_head.rb', line 42