Class: Git::Commands::Fetch Private

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

Implements the git fetch command

Downloads objects and refs from another repository. Fetches branches and/or tags from one or more other repositories, along with the objects necessary to complete their histories.

Examples:

Typical usage

fetch = Git::Commands::Fetch.new(execution_context)
fetch.call
fetch.call('origin')
fetch.call('origin', 'refs/heads/main')
fetch.call(all: true, prune: true)
fetch.call('origin', merge: 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(repository = nil, *refspec, **options) ⇒ Git::CommandLineResult

Execute the git fetch command

Parameters:

  • repository (String, nil) (defaults to: nil)

    (nil) the remote name or URL to fetch from

    When nil, git uses the default remote configured for the current branch.

  • refspec (Array<String>)

    one or more refspecs to fetch

    Each may be a branch name, a refspec pattern such as +refs/heads/*:refs/remotes/origin/*, or a commit SHA.

  • options (Hash)

    command options

Options Hash (**options):

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

    fetch all remotes (--all)

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

    do not fetch all remotes (--no-all)

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

    append ref names and object names of fetched refs to the existing contents of .git/FETCH_HEAD

    Alias: :a

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

    use an atomic transaction to update local refs

  • :depth (String) — default: nil

    limit fetching to the specified number of commits from the tip of each remote branch history

  • :deepen (String) — default: nil

    deepen or shorten history by the specified number of commits from the current shallow boundary

  • :shallow_since (String) — default: nil

    deepen or shorten the history to include all reachable commits after the given date

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

    exclude commits reachable from the specified remote branch or tag

    Repeatable.

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

    convert a shallow repository to a complete one, or fetch as much as possible from a shallow source

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

    accept refs that would normally require updating .git/shallow

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

    only report commits reachable from the given tips when negotiating

    Repeatable. The argument may be a ref, a glob on ref names, or an abbreviated SHA-1.

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

    do not fetch anything from the server; print ancestors of --negotiation-tip arguments that we have in common

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

    show what would be done without making changes

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

    print the output to standard output in an easy-to-parse format for scripts

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

    write the fetched remote refs to .git/FETCH_HEAD (--write-fetch-head)

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

    do not write fetched remote refs to .git/FETCH_HEAD (--no-write-fetch-head)

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

    override the fast-forward check when using explicit refspecs

    Alias: :f

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

    keep the downloaded pack

    Alias: :k

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

    allow several repository and group arguments to be specified

    When using this option, pass additional repository or group names as extra positional arguments; they are bound to the :refspec slot in the DSL but are passed through to git correctly.

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

    run automatic repository maintenance after fetching (--auto-maintenance)

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

    do not run automatic repository maintenance after fetching (--no-auto-maintenance)

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

    run automatic garbage collection after fetching — deprecated alias for :auto_maintenance (--auto-gc)

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

    do not run automatic garbage collection after fetching (--no-auto-gc)

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

    write a commit-graph after fetching (--write-commit-graph)

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

    do not write a commit-graph after fetching (--no-write-commit-graph)

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

    modify the configured refspec to place all refs into the refs/prefetch/ namespace

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

    before fetching, remove any remote-tracking references that no longer exist on the remote

    Alias: :p

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

    before fetching, remove any local tags that no longer exist on the remote (requires --prune)

    Alias: :P

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

    fetch all objects as a fresh clone would, bypassing negotiation

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

    use the specified refspec to map refs to remote-tracking branches instead of the configured remote.*.fetch values

    Repeatable.

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

    fetch all tags from the remote (--tags)

    Alias: :t

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

    disable automatic tag following (--no-tags)

  • :recurse_submodules (Boolean, String, nil) — default: nil

    control whether new commits of submodules should be fetched

    When true, uses --recurse-submodules. When a string (e.g. 'yes', 'on-demand', 'no'), passes that value.

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

    do not recurse into submodules (--no-recurse-submodules)

  • :jobs (String) — default: nil

    number of submodules or parallel fetches

    Alias: :j

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

    add upstream tracking reference if the remote is fetched successfully

  • :submodule_prefix (String) — default: nil

    prepend the given path to informative messages such as "Fetching submodule foo"

    Used internally when recursing over submodules.

  • :recurse_submodules_default (String) — default: nil

    provide a non-negative default value for --recurse-submodules

    Used internally.

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

    allow updating the HEAD that corresponds to the current branch

    Used internally by git pull.

    Alias: :u

  • :upload_pack (String) — default: nil

    specify a non-default path for git-upload-pack on the remote side

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

    suppress all output

    Alias: :q

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

    be verbose

    Alias: :v

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

    force progress status on standard error even when the stream is not attached to a terminal

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

    transmit the given string to the server when communicating using protocol version 2

    Repeatable.

    Alias: :o

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

    check for force-updated branches during fetch (--show-forced-updates)

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

    do not check for force-updated branches during fetch (--no-show-forced-updates)

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

    use IPv4 addresses only

    Alias: :"4"

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

    use IPv6 addresses only

    Alias: :"6"

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

    read refspecs from stdin in addition to those provided as arguments

  • :timeout (Numeric, nil) — default: nil

    maximum seconds to wait for the command to complete

    If nil, uses the global timeout from Git::Config.

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

    merge stderr into stdout in the returned result

    Pass true to capture git fetch output (which is written to stderr by default).

Returns:

Raises:

  • (ArgumentError)

    if unsupported options are provided

  • (Git::FailedError)

    if git exits with a non-zero exit status



# File 'lib/git/commands/fetch.rb', line 119