Package org.eclipse.jgit.api
Class InitCommand
- java.lang.Object
-
- org.eclipse.jgit.api.InitCommand
-
-
Constructor Summary
Constructors Constructor Description InitCommand()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Git
call()
InitCommand
setBare(boolean bare)
Set whether the repository is bare or notInitCommand
setDirectory(File directory)
The optional directory associated with the init operation.InitCommand
setFs(FS fs)
Set the file system abstraction to be used for repositories created by this command.InitCommand
setGitDir(File gitDir)
Set the repository meta directory (.git)InitCommand
setInitialBranch(String branch)
Set the initial branch of the new repository.
-
-
-
Method Detail
-
call
public Git call() throws GitAPIException
Executes the
Init
command.- Specified by:
call
in interfaceCallable<Git>
- Returns:
- a
Git
instance that owns theRepository
that it wraps. - Throws:
GitAPIException
-
setDirectory
public InitCommand setDirectory(File directory) throws IllegalStateException
The optional directory associated with the init operation. If no directory is set, we'll use the current directory- Parameters:
directory
- the directory to init to- Returns:
- this instance
- Throws:
IllegalStateException
- 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 specified
-
setGitDir
public InitCommand setGitDir(File gitDir) throws IllegalStateException
Set the repository meta directory (.git)- Parameters:
gitDir
- the repository meta directory- Returns:
- this instance
- Throws:
IllegalStateException
- 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 specified- Since:
- 3.6
-
setBare
public InitCommand setBare(boolean bare)
Set whether the repository is bare or not- Parameters:
bare
- whether the repository is bare or not- Returns:
- this instance
- Throws:
IllegalStateException
- 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 specified
-
setFs
public InitCommand setFs(FS fs)
Set the file system abstraction to be used for repositories created by this command.- Parameters:
fs
- the abstraction.- Returns:
this
(for chaining calls).- Since:
- 4.10
-
setInitialBranch
public InitCommand setInitialBranch(String branch) throws InvalidRefNameException
Set the initial branch of the new repository. If not specified (null
or empty), fall back to the default name (currently master).- Parameters:
branch
- initial branch name of the new repository- Returns:
this
- Throws:
InvalidRefNameException
- if the branch name is not valid- Since:
- 5.11
-
-