3

that I need to get all commits from a remote repository.

This is how I clone a repository to a local system, but it's not a good idea to download all files because there is so much.

git = Git.cloneRepository().setURI(repo).setDirectory(pathGit).call();
File pathRepo = new File(pathGit.getPath() + "/.git");
repository = FileRepositoryBuilder.create(pathRepo);

How to resolve this issue?

Rüdiger Herrmann
  • 20,512
  • 11
  • 62
  • 79
Daria
  • 347
  • 2
  • 5
  • 18
  • Where is your remote repository hosted? If it's on GitLab have a look at their API [list-repository-commits](https://docs.gitlab.com/ce/api/commits.html#list-repository-commits). If it's hosted somewhere else, check their API. – SubOptimal Mar 29 '17 at 12:42
  • Note, that in order to obtain the JGit repository instance `git.getRepository()` is sufficient. – Rüdiger Herrmann Mar 29 '17 at 18:26

1 Answers1

2

Cloning a repository is the only way to gain access to its history. If the time that it takes to clone a repository is an issue, you may want to cache it for future or shared access.

Git Hosting services like GitLab of GitHub may have specialized REST APIs to obtain commit metadata. However, these are specific to the respective service hoster.

Rüdiger Herrmann
  • 20,512
  • 11
  • 62
  • 79