@WithOperations(staticOperations=[InitOp, CloneOp, OpenOp], instanceOperations=[CleanOp, StatusOp, AddOp, RmOp, ResetOp, ApplyOp, PullOp, PushOp, FetchOp, LsRemoteOp, CheckoutOp, LogOp, CommitOp, RevertOp, MergeOp, DescribeOp, ShowOp]) class Grgit extends java.lang.Object
Provides support for performing operations on and getting information about a Git repository.
A Grgit instance can be obtained via 3 methods.
Open an existing repository.
def grgit = Grgit.open(dir: 'path/to/my/repo')
Initialize a new repository.
def grgit = Grgit.init(dir: 'path/to/my/repo')
Clone an existing repository.
def grgit = Grgit.clone(dir: 'path/to/my/repo', uri: 'git@github.com:ajoberstar/grgit.git')
Once obtained, operations can be called with two syntaxes.
Map syntax. Any public property on the *Op class can be provided as a Map entry.
grgit.commit(message: 'Committing my code.', amend: true)
Closure syntax. Any public property or method on the *Op class can be used.
grgit.log {
range 'master', 'my-new-branch'
maxCommits = 5
}
Details of each operation's properties and methods are available on the doc page for the class. The following operations are supported directly on a Grgit instance.
And the following operations are supported statically on the Grgit class.
Further operations are available on the following services.
| Type | Name and description |
|---|---|
BranchService |
branchSupports operations on branches. |
RemoteService |
remoteSupports operations on remotes. |
Repository |
repositoryThe repository opened by this object. |
ResolveService |
resolveConvenience methods for resolving various objects. |
TagService |
tagSupports operations on tags. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
void |
close()Release underlying resources used by this instance. |
|
Commit |
head()Returns the commit located at the current HEAD of the repository. |
|
boolean |
isAncestorOf(java.lang.Object base, java.lang.Object tip)Checks if base is an ancestor of tip. |
| Methods inherited from class | Name |
|---|---|
class java.lang.Object |
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Supports operations on branches.
Supports operations on remotes.
The repository opened by this object.
Convenience methods for resolving various objects.
Supports operations on tags.
Release underlying resources used by this instance. After calling close you should not use this instance anymore.
Returns the commit located at the current HEAD of the repository.
Checks if base is an ancestor of tip.
base - the version that might be an ancestortip - the tip version