Class: Git::Commands::Remote::Add Private

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

Adds a new remote to the repository, associating a name with a URL and configuring how tracking branches and tags are handled.

Examples:

Add a remote with a name and URL

add = Git::Commands::Remote::Add.new(execution_context)
add.call('origin', 'https://example.com/repo.git')

Add a remote and immediately fetch

add = Git::Commands::Remote::Add.new(execution_context)
add.call('upstream', 'https://example.com/upstream.git', fetch: true)

Track a specific branch and disable tag import

add = Git::Commands::Remote::Add.new(execution_context)
add.call('origin', 'https://example.com/repo.git', track: 'main', no_tags: 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, url, **options) ⇒ Git::CommandLineResult

Execute the git remote add command

Parameters:

  • name (String)

    the remote name to create

  • url (String)

    the remote URL to configure

  • options (Hash)

    command options

Options Hash (**options):

  • :track (String, Array<String>) — default: nil

    track only the given branch(es) during fetch

    Accepts a single branch name or an array; each value causes a separate --track flag.

    Alias: :t

  • :master (String) — default: nil

    set the remote HEAD symbolic ref to the given branch

    Alias: :m

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

    fetch the remote immediately after adding it

    Alias: :f

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

    import all tags from the remote (--tags)

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

    disable importing tags from the remote (--no-tags)

  • :mirror (String) — default: nil

    set mirror mode

    Common values are 'fetch' and 'push'.

Returns:

Raises:

  • (ArgumentError)

    if unsupported options are provided

  • (Git::FailedError)

    if git exits with a non-zero exit status



# File 'lib/git/commands/remote/add.rb', line 49