Method: RubyGit::Worktree.clone
- Defined in:
- lib/ruby_git/worktree.rb
.clone(repository_url, to_path: nil) ⇒ RubyGit::Worktree
Copy the remote repository and checkout the default branch
Clones the repository referred to by repository_url into a newly created
directory, creates remote-tracking branches for each branch in the cloned repository,
and checks out the default branch in the Git working tree whose root directory is to_path.
to_path will be created if it does not exist. An error is raised if to_path exists and
not an empty directory.
108 109 110 111 112 113 114 |
# File 'lib/ruby_git/worktree.rb', line 108 def self.clone(repository_url, to_path: nil) command = ['clone', '--', repository_url] command << to_path if to_path = { out: StringIO.new, err: StringIO.new } clone_output = RubyGit::CommandLine.run(*command, **).stderr new(cloned_to(clone_output)) end |