0
我將動態地創建本地分支(像 Hotfix_Test1,Hotfix_Test2每個在不同的時間),並把它推到遠程。git的新的本地分支創建然後推遠程分支(新遠程),然後設置上游使用JGIT
這些分支應包含在一個稱爲推出分支這是另一個本地
推出已經從本地用git推到遠程可用的源命令
- GIT中結帳-b釋放GIT中推
GIT中推--set上游原點推出
創建一個git對象,並試圖在F ollowing代碼以創建修復程序分支動態
當執行涉及到該行public static void main(String[] args) { CreateBranchCommand createBranchCommand = null; CheckoutCommand checkoutCommand = null; Git git = null; String releaseVersion = "Test"; PushCommand pushCommand = null; StoredConfig config = null; try { /* Consider Git object is created */ git = createGitObject(); /* Checkout Release branch */ checkoutCommand = git.checkout(); checkoutCommand.setName("Release"); checkoutCommand.call(); /* Creating Hotfix Branch */ createBranchCommand = git.branchCreate(); createBranchCommand.setName("hotfix_" + releaseVersion).call(); /* Pushing Hotfix Branch to remote * note that the hotfix is not present in remote */ pushCommand = git.push(); pushCommand.setRemote("origin"); pushCommand.setRefSpecs(new RefSpec("hotfix_" + releaseVersion + ":hotfix_" + releaseVersion)); pushCommand.call(); /* Trying to set upstream for newly created hotfix branch */ createBranchCommand.setUpstreamMode(SetupUpstreamMode.SET_UPSTREAM); createBranchCommand.setStartPoint("origin/" + "hotfix_" + releaseVersion); createBranchCommand.setForce(true); createBranchCommand.call(); checkoutCommand.setName("hotfix_" + releaseVersion); checkoutCommand.call(); /* Editing the configuration file in local */ config = git.getRepository().getConfig(); config.setString(ConfigConstants.CONFIG_BRANCH_SECTION, "hotfix_" + releaseVersion, "remote", "origin"); config.setString(ConfigConstants.CONFIG_BRANCH_SECTION, "hotfix_" + releaseVersion, "merge", "refs/heads/hotfix_" + releaseVersion); config.save(); } catch (Exception exception) { exception.printStackTrace(); } }
'createBranchCommand.setUpstreamMode(SetupUpstreamMode.SET_UPSTREAM);'
它拋出異常
- java.lang.IllegalStateException:命令org.eclipse.jgit.api.CreateBranchCommand被稱爲在錯誤的狀態
我不知道Wats的錯誤。請幫助解決這個錯誤。
請發佈完整的stacktrace給他人必要的d詳細地說它失敗了。 – centic