java - 通过 JGit 添加远程

标签 java git jgit

我在玩 JGit,我可以成功地从某个存储库中删除一个远程服务器 (git remote rm origin),我该怎么做 git remote add origin http://github.com/用户/ repo ?

要删除我执行以下操作:

StoredConfig config = git.getRepository().getConfig();
config.unsetSection("remote", "origin");
config.save();

但是没有像#setSection(String, String)这样的选项。

提前致谢。

最佳答案

管理它以这种方式工作:

Git git = new Git(localRepository);
StoredConfig config = git.getRepository().getConfig();
config.setString("remote", "origin", "url", "http://github.com/user/repo");
config.save();

关于java - 通过 JGit 添加远程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12799573/

相关文章:

java - Git/JGit 与 SVNKit 类似的 Java 访问代码(方法)

git - 如何在不克隆 GITHUB 的情况下查找 Git 存储库的修订 ID

java - ExecutorService 挂起

java - 使用 SpEL Autowiring 值 : referencing beans by type

git - 在 TFS 商店中使用 Git

git - 如何使用 git 从与主分支不同的分支中 pull ?

java - 如何通过 JFileChooser 将 JTable 保存到文本文件

java - 对于日期值数组,趋势值会通过 LinearRegression.java 返回地雷

git - git:如何以编程方式确定是否需要 pull 或 push ?

java - 在 JGit 中创建孤立分支和 rm -rf