Class: Git::Commands::Pull Private

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

Implements the git pull command

Incorporates changes from a remote repository into the current branch. In its default mode, git pull is shorthand for git fetch followed by git merge FETCH_HEAD.

Examples:

Pull from the default remote

pull = Git::Commands::Pull.new(execution_context)
pull.call

Pull from a named remote

pull = Git::Commands::Pull.new(execution_context)
pull.call('origin')

Pull a specific branch from a remote

pull = Git::Commands::Pull.new(execution_context)
pull.call('origin', 'main')

Pull with rebase instead of merge

pull = Git::Commands::Pull.new(execution_context)
pull.call('origin', rebase: true)

Pull with allow-unrelated-histories

pull = Git::Commands::Pull.new(execution_context)
pull.call('origin', 'feature', allow_unrelated_histories: true)

Pull and suppress the merge-commit editor

pull = Git::Commands::Pull.new(execution_context)
pull.call('origin', no_edit: 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, *refspecs, **options) ⇒ Git::CommandLineResult

Execute the git pull command

Returns the result of calling git pull.

Parameters:

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

    The remote name or URL to pull from

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

  • refspecs (Array<String>)

    Zero or more refspecs specifying which refs to fetch and merge

    Each may be a branch name or refspec pattern.

  • options (Hash)

    command options

Options Hash (**options):

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

    suppress all output

    Alias: :q

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

    enable verbose output during fetch and merge

    Alias: :v

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

    control submodule commit fetching (--recurse-submodules)

    Pass a string such as 'yes', 'on-demand', or 'no' for --recurse-submodules=<value>.

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

    disable submodule commit fetching (--no-recurse-submodules)

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

    perform the merge and commit the result (--commit)

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

    merge but do not commit the result (--no-commit)

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

    open an editor for the merge commit message (--edit)

    Alias: :e

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

    do not open an editor for the merge commit message (--no-edit)

  • :cleanup (String) — default: nil

    merge-message cleanup mode

    Determines how the merge message is cleaned up before committing. For example, 'strip', 'whitespace', 'verbatim', 'scissors', 'default'.

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

    require fast-forward merge or up-to-date HEAD

    Refuses to merge unless the current HEAD is already up to date or the merge can be resolved as a fast-forward.

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

    allow fast-forward merge (--ff)

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

    disable fast-forward merge, always creating a merge commit (--no-ff)

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

    GPG-sign the resulting merge commit (--gpg-sign)

    Pass a key-ID string to select the signing key. Alias: :S

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

    countermand commit.gpgSign configuration (--no-gpg-sign)

  • :log (Boolean, Integer, nil) — default: nil

    include one-line descriptions from the actual commits being merged in log message (--log)

    Pass an integer for --log=<n>.

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

    disable inclusion of one-line descriptions from merged commits (--no-log)

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

    add a Signed-off-by trailer to the resulting merge commit message (--signoff)

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

    remove a Signed-off-by trailer from the merge commit message (--no-signoff)

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

    show a diffstat at the end of the merge

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

    do not show a diffstat at the end of the merge

    Alias: :n

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

    show a compact summary after the merge

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

    squash pulled commits into a single commit (--squash)

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

    override --squash option (--no-squash)

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

    run pre-merge and commit-msg hooks (--verify)

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

    bypass pre-merge and commit-msg hooks (--no-verify)

  • :strategy (String) — default: nil

    use the given merge strategy

    For example, 'ort', 'recursive', 'resolve', 'octopus', 'ours', 'subtree'. Alias: :s

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

    pass option(s) to the merge strategy

    Can be a single value or array. For example, 'ours', 'theirs', 'patience'. Alias: :X

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

    verify that the tip commit of the side branch being merged is signed with a valid key (--verify-signatures)

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

    do not verify the signature of the side branch tip commit (--no-verify-signatures)

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

    show a summary after the merge (--summary)

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

    do not show a summary after the merge (--no-summary)

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

    automatically create a temporary stash entry before the operation begins (--autostash)

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

    disable automatic stashing before the operation (--no-autostash)

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

    allow pulling from a repository that shares no common history with the current repository

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

    rebase the current branch on top of the upstream branch after fetching (--rebase)

    Pass a string such as 'merges' or 'interactive' for --rebase=<value>. Alias: :r

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

    override earlier --rebase option (--no-rebase)

  • :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 fetched 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 given number of commits

    Fetches only the specified number of commits from the tip of each remote branch history.

  • :deepen (String) — default: nil

    deepen or shorten history of a shallow repository

  • :shallow_since (String) — default: nil

    deepen or shorten 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

    If the source is shallow, fetches as much as possible.

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

    accept refs that update .git/shallow

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

    report only commits reachable from the given tips during negotiation

    Repeatable.

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

    do not fetch; only print ancestries between the local repository and the remote

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

    show what would be done without making changes

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

    give the output in a stable, easy-to-parse format for scripts

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

    override the check for a non-fast-forward update

    Alias: :f

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

    keep the downloaded pack

    Alias: :k

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

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

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

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

    Alias: :p

  • :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)

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

    override fetch refspecs for remote-tracking branch mapping

    Repeatable.

  • :jobs (String) — default: nil

    number of submodules fetched in parallel

    Alias: :j

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

    add upstream (tracking) reference for the current branch

  • :upload_pack (String) — default: nil

    path to git-upload-pack on the remote

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

    force progress status display (--progress)

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

    suppress progress status display (--no-progress)

  • :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 whether a local branch is force-updated during fetch (--show-forced-updates)

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

    disable checking for force updates (--no-show-forced-updates)

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

    use IPv4 addresses only, ignoring IPv6 addresses

    Alias: :'4'

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

    use IPv6 addresses only, ignoring IPv4 addresses

    Alias: :'6'

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

    timeout in seconds for the command

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

Returns:

Raises:

  • (ArgumentError)

    if argument validation fails (e.g., unsupported options are provided or option values are invalid)

  • (Git::FailedError)

    if git exits with a non-zero exit status



# File 'lib/git/commands/pull.rb', line 115