gpt4 book ai didi

java - 在java中执行git blame命令

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:26:46 42 4
gpt4 key购买 nike

我正在尝试使用以下 Java 语法来执行 Git blame 命令:

Process process = Runtime.getRuntime().exec("/usr/bin/git blame https://github.com/git/git/alloc.c > TestGit.txt");

但是,当我用 Java 运行代码时,它没有给出任何结果。而且,当我尝试在终端中执行它时,它只会创建一个空的“TestGit.txt”文件,并且出现错误:fatal: Not a git repository (or any of the parent directories): .git

最佳答案

确保在启动命令之前将目录更改为 git 存储库

Process process = Runtime.getRuntime().exec("cd /path/to/repository; /usr/bin/git blame https://github.com/git/git/alloc.c > TestGit.txt");

关于java - 在java中执行git blame命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11039517/

42 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com