package hellogit; import java.io.File; import java.io.IOException; import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.storage.file.FileRepositoryBuilder; /** * * @author tdevries */ public class HelloGit { /** * @param args the command line arguments */ public static void main(String[] args) throws IOException { FileRepositoryBuilder builder = new FileRepositoryBuilder(); Repository repository = builder.setGitDir(new File("/Full/Path/To/Git/Repo/")) .readEnvironment() .findGitDir() .build(); ObjectId head = repository.resolve("HEAD"); System.out.println(head); } }