class Git::Commands::Branch::Copy
Implements the ‘git branch –copy` command for copying branches
This command copies a branch, together with its config and reflog. If the old branch name is omitted, copies the current branch.
@example Copy the current branch
copy = Git::Commands::Branch::Copy.new(execution_context) copy.call('new-branch-name')
@example Copy a specific branch
copy = Git::Commands::Branch::Copy.new(execution_context) copy.call('old-branch-name', 'new-branch-name')
@example Force copy (overwrite existing branch)
copy = Git::Commands::Branch::Copy.new(execution_context) copy.call('old-branch', 'existing-branch', force: true)
@note ‘arguments` block audited against git-scm.com/docs/git-branch/2.53.0
@see git-scm.com/docs/git-branch git-branch
@api private
Public Instance Methods
Source
# File lib/git/commands/branch/copy.rb, line 96 def call(*, **) super end
Executes the git branch –copy command to copy a branch
@overload call(new_branch, **options)
Copies the current branch to the new_branch @param new_branch [String] the new name for the copied branch @param options [Hash] command options @option options [Boolean, nil] :force (nil) allow copying even if new_branch already exists Alias: :f @return [Git::CommandLine::Result] the result of calling `git branch --copy` @raise [ArgumentError] if unsupported options are provided @raise [Git::FailedError] if git exits with a non-zero exit status @api public
@overload call(old_branch, new_branch, **options)
Copies old_branch to new_branch @param old_branch [String] branch to copy from @param new_branch [String] the new name for the copied branch @param options [Hash] command options @option options [Boolean, nil] :force (nil) allow copying even if new_branch already exists Alias: :f @return [Git::CommandLine::Result] the result of calling `git branch --copy` @raise [ArgumentError] if unsupported options are provided @raise [Git::FailedError] if git exits with a non-zero exit status @api public
Calls superclass method
Git::Commands::Base::call