Class InitCommand

  • All Implemented Interfaces:
    java.util.concurrent.Callable<Git>

    public class InitCommand
    extends java.lang.Object
    implements java.util.concurrent.Callable<Git>
    Create an empty git repository or reinitalize an existing one
    See Also:
    Git documentation about init
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private boolean bare  
      private java.io.File directory  
      private FS fs  
      private java.io.File gitDir  
    • Constructor Summary

      Constructors 
      Constructor Description
      InitCommand()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Git call()
      InitCommand setBare​(boolean bare)
      Set whether the repository is bare or not
      InitCommand setDirectory​(java.io.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​(java.io.File gitDir)
      Set the repository meta directory (.git)
      private static void validateDirs​(java.io.File directory, java.io.File gitDir, boolean bare)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • directory

        private java.io.File directory
      • gitDir

        private java.io.File gitDir
      • bare

        private boolean bare
      • fs

        private FS fs
    • Constructor Detail

      • InitCommand

        public InitCommand()
    • Method Detail

      • call

        public Git call()
                 throws GitAPIException

        Executes the Init command.

        Specified by:
        call in interface java.util.concurrent.Callable<Git>
        Returns:
        a Git instance that owns the Repository that it wraps.
        Throws:
        GitAPIException
      • setDirectory

        public InitCommand setDirectory​(java.io.File directory)
                                 throws java.lang.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:
        java.lang.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​(java.io.File gitDir)
                              throws java.lang.IllegalStateException
        Set the repository meta directory (.git)
        Parameters:
        gitDir - the repository meta directory
        Returns:
        this instance
        Throws:
        java.lang.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​(java.io.File directory,
                                         java.io.File gitDir,
                                         boolean bare)
                                  throws java.lang.IllegalStateException
        Throws:
        java.lang.IllegalStateException
      • 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:
        java.lang.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