我無法弄清楚如何刪除遠程分支。如何使用JGit刪除遠程分支
我試圖模仿下面的GIT命令: 混帳推產地:branchToDelete
下面的代碼,並將其與空的源變化:
RefSpec refSpec = new RefSpec();
refSpec = refSpec.setSource("");
// remove branch from origin:
git.push().setRefSpecs(refSpec).add(branchToDelete).call();
拋出和異常,如:
org.eclipse.jgit.api.errors.JGitInternalException: Exception caught during execution of push command
at org.eclipse.jgit.api.PushCommand.call(PushCommand.java:175)
at org.gitscripts.DeleteBranchOperation.execute(DeleteBranchOperation.java:27)
at org.gitscripts.Main.main(Main.java:27)
Caused by: java.io.IOException: Source ref doesnt resolve to any object.
at org.eclipse.jgit.transport.RemoteRefUpdate.<init>(RemoteRefUpdate.java:285)
at org.eclipse.jgit.transport.RemoteRefUpdate.<init>(RemoteRefUpdate.java:189)
at org.eclipse.jgit.transport.Transport.findRemoteRefUpdatesFor(Transport.java:612)
at org.eclipse.jgit.transport.Transport.findRemoteRefUpdatesFor(Transport.java:1150)
at org.eclipse.jgit.api.PushCommand.call(PushCommand.java:149)
... 2 more
在此先感謝您的想法和解決方案。
從你的錯誤看來你的refSpec有問題。你確定它是正確的? – 2012-08-09 22:18:43