Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JGit : connect to distant repository

I searched through Google, forums and JGit user guide but couldn't find how to connect to a distant repository with the API. Anyone has an example or just an idea on how to do that?

Thanks for your help.

like image 572
Brice Avatar asked Apr 25 '12 08:04

Brice


1 Answers

Currently, JGit 2.0.0-SNAPSHOT does only offer

org.eclipse.jgit.storage.file.FileRepository
org.eclipse.jgit.storage.dfs.InMemoryRepository

concrete Repository classes, meaning that since org.eclipse.jgit.api.Git takes a Repository, it is not possible to work remotely. Since Git by itself is not designed to operate remotely in the way I think you mean, I doubt we will see such a feature any time soon.

MORE ON THAT:

Consequently, you will need to clone locally. You do that by issuing

    Git.cloneRepository()
       .setURI(myRemoteURIString)
       .setDirectory(new File(myLocalPathString))
       .call();

However, for reasons of consistency in Git you should clone a bare repository only, so a non-bare repository in a remote location, while not technically, is practically inaccessible.

like image 57
Luca Geretti Avatar answered Oct 04 '22 00:10

Luca Geretti