Package org.eclipse.jgit.api
Class InitCommand
java.lang.Object
org.eclipse.jgit.api.InitCommand
Create an empty git repository or reinitalize an existing one
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncall()
setBare
(boolean bare) Set whether the repository is bare or notsetDirectory
(File directory) The optional directory associated with the init operation.Set the file system abstraction to be used for repositories created by this command.Set the repository meta directory (.git)setInitialBranch
(String branch) Set the initial branch of the new repository.private static void
validateDirs
(File directory, File gitDir, boolean bare)
-
Field Details
-
directory
-
gitDir
-
bare
private boolean bare -
fs
-
initialBranch
-
-
Constructor Details
-
InitCommand
public InitCommand()
-
-
Method Details
-
call
Executes the
Init
command.- Specified by:
call
in interfaceCallable<Git>
- Returns:
- a
Git
instance that owns theRepository
that it wraps. - Throws:
GitAPIException
-
setDirectory
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
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
-
validateDirs
private static void validateDirs(File directory, File gitDir, boolean bare) throws IllegalStateException - Throws:
IllegalStateException
-
setBare
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
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
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
-