JGit:连接到远程存储库 [英] JGit : connect to distant repository
问题描述
我搜索了 Google、论坛和 JGit 用户指南,但找不到如何使用 API 连接到远程存储库.任何人都有一个例子或只是一个关于如何做到这一点的想法?
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?
感谢您的帮助.
推荐答案
目前,JGit 2.0.0-SNAPSHOT 只提供
Currently, JGit 2.0.0-SNAPSHOT does only offer
org.eclipse.jgit.storage.file.FileRepository
org.eclipse.jgit.storage.dfs.InMemoryRepository
具体的Repository
类,意味着由于org.eclipse.jgit.api.Git
需要一个Repository
,所以无法工作远程.由于 Git 本身并没有像我想的那样设计为远程操作,我怀疑我们很快就会看到这样的功能.
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.
更多信息:
因此,您需要在本地进行克隆.你通过发出
Consequently, you will need to clone locally. You do that by issuing
Git.cloneRepository()
.setURI(myRemoteURIString)
.setDirectory(new File(myLocalPathString))
.call();
然而,为了在 Git 中保持一致性,您应该只克隆一个裸仓库,因此远程位置的非裸仓库虽然不是技术上的,但实际上是无法访问的.
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.
这篇关于JGit:连接到远程存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!