![](/img/trans.png)
[英]Getting exception “org.eclipse.jgit.api.errors.InvalidConfigurationException: No value for key remote” at JGit
[英]Getting InvalidConfigurationException in JGit while pulling remote branch
我試圖將遠程主分支拉到當前已簽出的本地分支中。 這是它的代碼
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/*
這似乎是JGit中的錯誤。 根據setRemote()
的JavaDoc,它設置了用於進行拉操作的遠程對象( uri或name ),但顯然只有遠程名稱有效。
根據您的配置,您可以使用以下遠程名稱來解決此問題:
pullCommand.setRemote( "origin" );
我建議在JGit bugzilla中打開一個錯誤報告 ,以便在以后的JGit版本中修復該問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.