当前设置
我有一个启用了git lfs的存储库。访问存储lfs内容的驱动器时,还存在另一级身份验证。在从命令提示符运行下面的代码时,它会要求输入用户名和密码以访问lfs内容,如下所示:
如果我们使用没有LFS内容身份验证的另一个存储库,则一切都可以正常工作。 请告诉我如何从JGIT中取消身份验证,或者如何跳过获取LFS内容。 请告诉我是否有任何错误操作。
详细信息:
1)使用以下JGit版本4.9.0.201710071750-r
2)已安装git lfs
代码片段
public static void syncRepository(String uname, String pwd, String url, String destDir) throws Exception{
String branch = "refs/heads/master";
System.out.println("Cloning from ["+url+"] branch ["+branch+"] to ["+destDir.toString()+"]");
String workingDirPath = null;
try {
if (StringUtils.isNotEmpty(destDir)) {
workingDirPath = FilenameUtils.normalize(destDir);
} else {
throw new Exception("Working directory for code sync not found : " + destDir);
}
Path path = Paths.get(workingDirPath);
System.out.println("Deleting '" +workingDirPath+ "' and re-creating empty destination dir" );
recursivelyDelete(path.toFile());
Files.createDirectories(Paths.get(workingDirPath));
Path targetPath = path.resolve("");
// clone repository
Git git = cloneRepository(url, uname, pwd, branch, targetPath);
System.out.println("Git revision # " + getLastHash(git));
System.out.println("SYNC Repository completed");
} catch (GitAPIException e) {
// if the import fails then we should try to remove the created directory
System.out.println("Failed to clone git repository."+ e);
throw new Exception("Failed to clone git repository", e);
}
}
private static Git cloneRepository(String url, String username, String password, String branch, Path targetPath)
throws Exception {
Git result;
try {
CloneCommand cloneCommand = Git.cloneRepository()
.setProgressMonitor(new TextProgressMonitor(new PrintWriter(System.out)))
.setURI(url).setBranch(branch)
.setDirectory(targetPath.toFile())
.setTimeout(300)
.setTransportConfigCallback(new TransportConfigCallback() {
public void configure(Transport transport) {
transport.setTimeout(300);
}
});
setCredentials(cloneCommand, username, password);
result = cloneCommand.call();
return result;
} catch (GitAPIException e) {
// if the import fails then we should try to remove the created directory
throw new Exception("Failed to clone git repository", e);
}
}