public class CloneCommand extends TransportCommand<CloneCommand,Git>
Modifier and Type | Class and Description |
---|---|
static interface |
CloneCommand.Callback
Callback for status of clone operation.
|
credentialsProvider, timeout, transportConfigCallback
repo
Constructor and Description |
---|
CloneCommand()
Create clone command with no repository set
|
Modifier and Type | Method and Description |
---|---|
Git |
call() |
CloneCommand |
setBare(boolean bare)
Set whether the cloned repository shall be bare
|
CloneCommand |
setBranch(String branch)
Set the initial branch
|
CloneCommand |
setBranchesToClone(Collection<String> branchesToClone)
Set the branches or tags to clone.
|
CloneCommand |
setCallback(CloneCommand.Callback callback)
Register a progress callback.
|
CloneCommand |
setCloneAllBranches(boolean cloneAllBranches)
Set whether all branches have to be fetched.
|
CloneCommand |
setCloneSubmodules(boolean cloneSubmodules)
Set whether to clone submodules
|
CloneCommand |
setDirectory(File directory)
The optional directory associated with the clone operation.
|
CloneCommand |
setFs(FS fs)
Set the file system abstraction to be used for repositories created by
this command.
|
CloneCommand |
setGitDir(File gitDir)
Set the repository meta directory (.git)
|
CloneCommand |
setNoCheckout(boolean noCheckout)
Set whether to skip checking out a branch
|
CloneCommand |
setProgressMonitor(ProgressMonitor monitor)
The progress monitor associated with the clone operation.
|
CloneCommand |
setRemote(String remote)
The remote name used to keep track of the upstream repository for the
clone operation.
|
CloneCommand |
setURI(String uri)
Set the URI to clone from
|
configure, configure, self, setCredentialsProvider, setTimeout, setTransportConfigCallback
checkCallable, getRepository, setCallable
public Git call() throws GitAPIException, InvalidRemoteException, TransportException
Execute the command
Executes the Clone
command.
The Git instance returned by this command needs to be closed by the
caller to free resources held by the underlying Repository
instance. It is recommended to call this method as soon as you don't need
a reference to this Git
instance and the underlying
Repository
instance anymore.
call
in interface Callable<Git>
call
in class GitCommand<Git>
GitAPIException
InvalidRemoteException
TransportException
public CloneCommand setURI(String uri)
uri
- the URI to clone from, or null
to unset the URI. The
URI must be set before call()
is called.public CloneCommand setDirectory(File directory)
directory
- the directory to clone to, or null
if the directory
name should be taken from the source uriIllegalStateException
- if the combination of directory, gitDir and bare is illegal.
E.g. if for a non-bare repository directory and gitDir point
to the same directory of if for a bare repository both
directory and gitDir are specifiedURIish.getHumanishName()
public CloneCommand setGitDir(File gitDir)
gitDir
- the repository meta directory, or null
to choose one
automatically at clone timeIllegalStateException
- if the combination of directory, gitDir and bare is illegal.
E.g. if for a non-bare repository directory and gitDir point
to the same directory of if for a bare repository both
directory and gitDir are specifiedpublic CloneCommand setBare(boolean bare) throws IllegalStateException
bare
- whether the cloned repository is bare or notIllegalStateException
- if the combination of directory, gitDir and bare is illegal.
E.g. if for a non-bare repository directory and gitDir point
to the same directory of if for a bare repository both
directory and gitDir are specifiedpublic CloneCommand setFs(FS fs)
fs
- the abstraction.this
(for chaining calls).public CloneCommand setRemote(String remote)
Constants.DEFAULT_REMOTE_NAME
will be used.remote
- name that keeps track of the upstream repository.
null
means to use DEFAULT_REMOTE_NAME.Constants.DEFAULT_REMOTE_NAME
public CloneCommand setBranch(String branch)
branch
- the initial branch to check out when cloning the repository.
Can be specified as ref name (refs/heads/master
),
branch name (master
) or tag name
(v1.2.3
). The default is to use the branch
pointed to by the cloned repository's HEAD and can be
requested by passing null
or HEAD
.public CloneCommand setProgressMonitor(ProgressMonitor monitor)
NullProgressMonitor
monitor
- a ProgressMonitor
this
NullProgressMonitor
public CloneCommand setCloneAllBranches(boolean cloneAllBranches)
If false
, use setBranchesToClone(Collection)
to define
what will be cloned. If neither are set, all branches will be cloned.
cloneAllBranches
- true
when all branches have to be fetched (indicates
wildcard in created fetch refspec), false
otherwise.this
public CloneCommand setCloneSubmodules(boolean cloneSubmodules)
cloneSubmodules
- true to initialize and update submodules. Ignored when
setBare(boolean)
is set to true.this
public CloneCommand setBranchesToClone(Collection<String> branchesToClone)
This is ignored if setCloneAllBranches(true)
is used. If branchesToClone
is
null
or empty, it's also ignored and all branches will be cloned.
branchesToClone
- collection of branches to clone. Must be specified as full ref
names (e.g. refs/heads/master
or
refs/tags/v1.0.0
).this
public CloneCommand setNoCheckout(boolean noCheckout)
noCheckout
- if set to true
no branch will be checked out
after the clone. This enhances performance of the clone
command when there is no need for a checked out branch.this
public CloneCommand setCallback(CloneCommand.Callback callback)
callback
- the callbackthis
Copyright © 2019 Eclipse JGit Project. All rights reserved.