2013-08-01 34 views
1

隨着jgit,我克隆一個git倉庫的主分支,然後我我檢查了遠程分支與此不能jgit的git拉所檢查出的分支

git.checkout() 
.setCreateBranch(true) 
.setName(branch) 
.setUpstreamMode(CreateBranchCommand.SetupUpstreamMode.TRACK) 
.setStartPoint(s"origin/$branch") 
.setForce(true) 
.call() 

然後我試圖與git拉在這個分支,

git.pull()()調用

,但最終與此錯誤

Exception in thread "main" org.eclipse.jgit.api.errors.InvalidConfigurationException: No value for key branch.X.Y.Z.merge found in configuration 
at org.eclipse.jgit.api.PullCommand.call(PullCommand.java:217) 
at com.baml.cesium.sphinx.token.TestGIT$delayedInit$body.apply(TestGIT.scala:52) 
at scala.Function0$class.apply$mcV$sp(Function0.scala:40) 
at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12) 
at scala.App$$anonfun$main$1.apply(App.scala:71) 
at scala.App$$anonfun$main$1.apply(App.scala:71) 
at scala.collection.immutable.List.foreach(List.scala:318) 
at scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:32) 
at scala.App$class.main(App.scala:71) 
at com.baml.cesium.sphinx.token.TestGIT$.main(TestGIT.scala:15) 
at com.baml.cesium.sphinx.token.TestGIT.main(TestGIT.scala) 

我發現簽出的分支沒有在.git/config中更新,這可能是此錯誤消息的原因。那麼這個配置是否可以通過checkout進行更新,或者jgit實際上是否允許在檢出分支上進行git pull?

(我知道我可以直接與jgit克隆的一個分支,但我還是想找出上述答案)

謝謝!

+0

你能不能也包括'git的/ config'這裏的內容是什麼? – robinst

回答

1

嘗試設置該配置事先:

StoredConfig config = git.getRepository().getConfig(); 
config.setString("branch", "master", "merge", "refs/heads/master");