Class Git


  • public class Git
    extends java.lang.Object
    Offers a "GitPorcelain"-like API to interact with a git repository.

    The GitPorcelain commands are described in the Git Documentation.

    This class only offers methods to construct so-called command classes. Each GitPorcelain command is represented by one command class.
    Example: this class offers a commit() method returning an instance of the CommitCommand class. The CommitCommand class has setters for all the arguments and options. The CommitCommand class also has a call method to actually execute the commit. The following code show's how to do a simple commit:

     Git git = new Git(myRepo);
     git.commit().setMessage("Fix393").setAuthor(developerIdent).call();
     
    All mandatory parameters for commands have to be specified in the methods of this class, the optional parameters have to be specified by the setter-methods of the Command class.

    This class is intended to be used internally (e.g. by JGit tests) or by external components (EGit, third-party tools) when they need exactly the functionality of a GitPorcelain command. There are use-cases where this class is not optimal and where you should use the more low-level JGit classes. The methods in this class may for example offer too much functionality or they offer the functionality with the wrong arguments.

    • Constructor Detail

      • Git

        public Git​(Repository repo)
        Constructs a new Git object which can interact with the specified git repository. All command classes returned by methods of this class will always interact with this git repository.
        Parameters:
        repo - the git repository this class is interacting with. null is not allowed