我试图在我当前检出的本地分支中拉出远程主分支。这是代码
checkout.setName(branchName).call();
PullCommand pullCommand = git.pull();
System.out.println("Pulling master into " + branchName + "...");
StoredConfig config = git.getRepository().getConfig();
config.setString("branch", "master", "merge", "refs/heads/master");
pullCommand.setRemote("https://github.com/blackblood/TattooShop.git");
pullCommand.setRemoteBranchName("master");
pullResult = pullCommand.setCredentialsProvider(credentialsProvider).call();
当我运行代码时,我在此行pullCommand.setRemote("https://github.com/blackblood/TattooShop.git");
错误:
org.eclipse.jgit.api.errors.InvalidConfigurationException:
No value for key remote.https://github.com/blackblood/TattooShop.git.url found in configurationCouldn't pull from remote. Terminating...
at org.eclipse.jgit.api.PullCommand.call(PullCommand.java:247)
at upload_gen.Launcher.updateFromRemote(Launcher.java:179)
at upload_gen.Launcher.main(Launcher.java:62)
以下是我的.git / config文件的内容
[core]
repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
symlinks = false
ignorecase = true
hideDotFiles = dotGitOnly
[remote "origin"]
url = https://github.com/blackblood/TattooShop.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
[remote "heroku"]
url = git@heroku.com:tattooshop.git
fetch = +refs/heads/*:refs/remotes/heroku/*
答案 0 :(得分:1)
这似乎是JGit中的一个错误。根据{{1}}的JavaDoc,它将远程( uri或名称)设置为用于拉取操作,但显然只有远程名称可用。< / p>
根据您的配置,您可以使用如下的远程名称解决此问题:
setRemote()
我建议在JGit bugzilla中打开bug report,以便在将来的JGit版本中修复此问题。