有没有办法在中途终止克隆操作? 我将只使用克隆来验证存储库吗? 有没有其他方法可以测试远程 url/存储库是否有效?
最佳答案
您可以使用 JGIT 调用“git ls-remote”。见 here
示例代码如下:
final LsRemoteCommand lsCmd = new LsRemoteCommand(null);
final List<String> repos = Arrays.asList(
"https://github.com/MuchContact/java.git",
"git@github.com:MuchContact/java.git");
for (String gitRepo: repos){
lsCmd.setRemote(gitRepo);
System.out.println(lsCmd.call().toString());
}
关于java - JGIT 验证存储库是否有效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11031244/