Class: Git::Commands::Push Private

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

Implements the git push command

Updates remote refs using local refs, while sending objects necessary to complete the given refs.

Examples:

Push to the default remote

push = Git::Commands::Push.new(execution_context)
push.call

Push to a named remote

push = Git::Commands::Push.new(execution_context)
push.call('origin')

Push a specific branch to a remote

push = Git::Commands::Push.new(execution_context)
push.call('origin', 'main')

Force push to a remote branch

push = Git::Commands::Push.new(execution_context)
push.call('origin', 'main', force: true)

Push with a server-side option

push = Git::Commands::Push.new(execution_context)
push.call('origin', push_option: 'ci.skip')

Push all tags to a remote

push = Git::Commands::Push.new(execution_context)
push.call('origin', 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(repository = nil, *refspecs, **options) ⇒ Git::CommandLineResult

Execute the git push command

Returns the result of calling git push.

Parameters:

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

    The remote name or URL to push to

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

  • refspecs (Array<String>)

    Zero or more refspecs specifying which refs to push

    Each may be a branch name or a full refspec pattern such as refs/heads/main:refs/heads/main. When no refspecs are given, git uses the push configuration for the current branch.

  • options (Hash)

    command options

Options Hash (**options):

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

    push all branches

    Alias: :branches

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

    push all refs under refs/ to the remote

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

    push all refs under refs/tags/

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

    push reachable annotated tags (--follow-tags)

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

    do not push reachable annotated tags (--no-follow-tags)

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

    use an atomic transaction to update remote refs (--atomic)

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

    disable atomic transaction for remote updates (--no-atomic)

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

    do not send updates, only report what would be pushed

    Alias: :n

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

    produce machine-readable output

  • :receive_pack (String) — default: nil

    path to the git-receive-pack program on the remote end

    Alias: :exec

  • :repo (String) — default: nil

    use this repository instead of the positional repository argument

    Equivalent to the positional <repository> argument. If both are given, the positional argument takes precedence.

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

    force updates, overriding the fast-forward check

    Alias: :f

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

    delete all listed refs from the remote repository

    Alias: :d

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

    remove remote branches that have no local counterpart

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

    suppress all output

    Alias: :q

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

    run verbosely

    Alias: :v

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

    set upstream tracking for each successfully pushed branch

    Alias: :u

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

    transmit one or more server-side options

    Repeatable. Each occurrence emits a separate --push-option=<value> flag.

    Alias: :o

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

    GPG-sign the push certificate (--signed)

    When a String ('true', 'false', 'if-asked'), emits --signed=<value>.

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

    disable GPG signing of the push certificate (--no-signed)

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

    refuse force pushes unless the remote ref matches the expected value (--force-with-lease)

    When a String (e.g. 'main:abc123'), emits --force-with-lease=<string>.

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

    disable force-with-lease (--no-force-with-lease)

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

    force pushes only if commits being pushed are already in the remote-tracking branch (--force-if-includes)

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

    disable force-if-includes (--no-force-if-includes)

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

    run the pre-push hook (--verify)

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

    bypass the pre-push hook (--no-verify)

  • :recurse_submodules (String) — default: nil

    control whether submodule commits are pushed

    Pass a String ('check', 'on-demand', 'only', 'no') to emit --recurse-submodules=<value>. Note: passing true is not valid; git requires an explicit value for this option.

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

    disable submodule push (--no-recurse-submodules)

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

    send a "thin" pack to reduce network traffic (--thin)

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

    send a full pack instead of a thin pack (--no-thin)

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

    force progress reporting even when stderr is not a terminal

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

    use IPv4 addresses only

    Alias: :"4"

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

    use IPv6 addresses only

    Alias: :"6"

  • :timeout (Integer) — default: nil

    maximum seconds to wait for the command to complete

Returns:

Raises:

  • (ArgumentError)

    if unsupported options are provided

  • (Git::FailedError)

    if git exits with a non-zero exit status



# File 'lib/git/commands/push.rb', line 109