Class: Git::Commands::Branch::Delete Private

Inherits:
Git::Commands::Base show all
Defined in:
lib/git/commands/branch/delete.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-branch/2.53.0

Implements the git branch --delete command for deleting branches

Examples:

Delete a single branch

delete = Git::Commands::Branch::Delete.new(execution_context)
result = delete.call('feature-branch')

Delete multiple branches

delete = Git::Commands::Branch::Delete.new(execution_context)
result = delete.call('branch1', 'branch2')

Force delete (works even if not merged)

delete = Git::Commands::Branch::Delete.new(execution_context)
result = delete.call('feature-branch', force: true)

Delete remote-tracking branch

delete = Git::Commands::Branch::Delete.new(execution_context)
result = delete.call('origin/feature', remotes: true)

See Also:

Instance Method Summary collapse

Methods inherited from Git::Commands::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(*branch_name, **options) ⇒ Git::CommandLineResult

Execute the git branch --delete command to delete branches

Returns the result of calling git branch --delete.

Parameters:

  • branch_name (Array<String>)

    One or more branch names to delete.

  • options (Hash)

    command options

Options Hash (**options):

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

    allow deleting the branch irrespective of its merged status, or whether it even points to a valid commit. This is equivalent to the -D shortcut (--delete --force).

    Alias: :f

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

    delete remote-tracking branches. Use this together with --delete to delete remote-tracking branches. Note that this only makes sense if the remote-tracking branches no longer exist in the remote repository or if git fetch was configured not to fetch them again.

    Alias: :r

Returns:

Raises:

  • (ArgumentError)

    if no branch names are provided

  • (Git::FailedError)

    if git exits outside the allowed range (exit code > 1)



# File 'lib/git/commands/branch/delete.rb', line 49