java - ProcessBuilder:Git 存储库不下载
问题描述
我正在使用 ProcessBuilder 从 Git 下载。这是我当前的代码:
Process process = null;
try {
String[] command = {"git", "clone", gitLink};
ProcessBuilder processBuilder = new ProcessBuilder(command);
processBuilder.directory(new File(gitPath));
process = processBuilder.start();
System.out.println("\n*** Console output is:");
InputStream processStdOutput = process.getInputStream();
Reader r = new InputStreamReader(processStdOutput);
BufferedReader br = new BufferedReader(r);
String line;
while ((line = br.readLine()) != null) { System.out.println("\t" + line); }
process.getOutputStream().close();
} catch (IOException e) { e.printStackTrace(); }
finally { if (process != null) { process.destroy(); } }
因此,gitLink
这将是我要下载的存储库的实际链接,并且gitPath
是在我的 PC 上下载到的位置。gitPath
似乎有效,因为我通过执行 command 对其进行了测试ls
。gitLink
,但是,什么也没显示。我得到了 Git 存储库一秒钟(在正确的gitPath
文件夹中),然后它就消失了。此外,当我使用 Git 存储库的实际链接而不是变量gitLink
时,它可以完美运行。出于某种原因,它不喜欢变量 gitLink。
这是有效的代码:
String[] command = {"git", "clone", "https://some-rep.git"};
其他的事情是平等的。
解决方案
推荐阅读
- reactjs - TypeError:无法读取未定义的属性“tipodecontato”
- amazon-web-services - 无法从 vpc 服务器将文件复制到 s3 或从 s3 复制文件:“无法找到凭据”
- c# - Swagger UI 响应示例 Asp.Net Core Web Api
- python - 无法在 Django 中使用 javascript 提交 csrf 令牌
- r - 混合效应条件逻辑回归误差
- python-3.x - 检查目标时出错:预期的 dense_ 具有 3 个维度,但得到了形状为 (100, 4) 的数组
- swift - 使用 AVWriter/AVReader 从 .mp4 视频写入零字节文件中提取 .wav 音频的 Swift 代码
- r - 如何在 R 的线性回归中测试变量作为混淆?
- python - 我做了一个“吃”和移除其他精灵的功能,但它不起作用并导致它们在被移除后继续移动
- vue.js - Vue 样式(背景图像)绑定不响应