Reference

Porcelain API

While JGit contains a lot of low level code to work with Git repositories, it also contains a higher level API that mimics some of the Git porcelain commands in the org.eclipse.jgit.api package.

Most users of JGit should start here.

AddCommand (git-add)

AddCommand allows you to add files to the index and has options available via its setter methods.

Here's a quick example of how to add a set of files to the index using the porcelain API.

Git git = new Git(db);
AddCommand add = git.add();
add.addFilepattern("someDirectory").call();

CommitCommand (git-commit)

CommitCommand allows you to perform commits and has options available via its setter methods.

Here's a quick example of how to commit using the porcelain API.

Git git = new Git(db);
CommitCommand commit = git.commit();
commit.setMessage("initial commit").call();

TagCommand (git-tag)

TagCommand supports a variety of tagging options through its setter methods.

Here's a quick example of how to tag a commit using the porcelain API.

Git git = new Git(db);
RevCommit commit = git.commit().setMessage("initial commit").call();
RevTag tag = git.tag().setName("tag").call();

LogCommand (git-log)

LogCommand allows you to easily walk a commit graph.

Here's a quick example of how get some log messages.

Git git = new Git(db);
Iterable<RevCommit> log = git.log().call();

MergeCommand (git-merge)

TODO

Ant Tasks

JGit has Ant tasks for some common tasks contained in the org.eclipse.jgit.ant bundle.

To use these tasks:

   <taskdef resource="org/eclipse/jgit/ant/ant-tasks.properties">
       <classpath>
         <pathelement location="path/to/org.eclipse.jgit.ant-VERSION.jar"/>
         <pathelement location="path/to/org.eclipse.jgit-VERSION.jar"/>
         <pathelement location="path/to/jsch-0.1.44-1.jar"/>
       </classpath>
   </taskdef>

This would then provide git-clone, git-init and git-checkout tasks.

git-clone

   <git-clone uri="http://egit.eclipse.org/jgit.git" />

The following attributes are required:

The following attributes are optional:

git-init

   <git-init />

The following attributes are optional:

git-checkout

   <git-checkout src="path/to/repo" branch="origin/experimental" />

The following attributes are required:

The following attributes are optional:

git-add

TODO