如何在jGit中使用fetch命令?

问题描述 投票:0回答:1

这是我添加远程的代码。

  FileRepositoryBuilder builder = new FileRepositoryBuilder();
            Repository repository = builder.setGitDir(gitdir)
                    .readEnvironment() // scan environment GIT_* variables
                    .findGitDir() // scan up the file system tree
                    .build();
            Git git = new Git(repository);

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

现在如何使用jGit使用fetch命令?

java git jgit
1个回答
0
投票

你可以使用JGit FetchCommand

git.fetch().setRemote("origin").call();
© www.soinside.com 2019 - 2024. All rights reserved.