List branches of a git remote repo without cloning it

六眼飞鱼酱① 提交于 2019-12-05 04:45:28

There is the LsRemoteCommand to list the branches of a remote repository. To obtain the command, use either

Git.wrap( repo ).lsRemote()

or

Git.lsRemoteRepository()

The statically created LsRemoteCommand has its limitations. For certain transport protocols, a local repository is necessary to obtain configuration settings. Therefore I usually create an empty temporary local repository with Git.init() and then use the first approach.

If you want to avoid creating the extra repository, you can test with Transport.open() if it succeeds without a repository. It throws a NotSupportedException otherwise.

Ok, never mind, after hours searching for the answer, I find it right before asking it there...

So, the answer is in the CookBook :

Collection<Ref> refs = Git.lsRemoteRepository()
            .setHeads(true)
            .setTags(true)
            .setRemote(REMOTE_URL)
            .call();
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!