git 创建新的本地分支然后推送远程分支(新远程)然后使用 JGIT 设置上游

git new local branch creation then push remote branch(new remote) and then set upstream using JGIT

它抛出异常

我不知道错在哪里。请帮忙解决错误。

您已经调用了 createdBranchCommand:

/* Creating Hotfix Branch */
createBranchCommand = git.branchCreate();
createBranchCommand.setName("hotfix_" + releaseVersion).call();

然后在再次尝试重新使用该 branchCreate() 命令之前进行了推送:

/* Trying to set upstream for newly created hotfix branch */
createBranchCommand.setUpstreamMode(SetupUpstreamMode.SET_UPSTREAM);
createBranchCommand.setStartPoint("origin/" + "hotfix_" + releaseVersion);
createBranchCommand.setForce(true);
createBranchCommand.call();

尝试一次创建分支并设置其上游配置,然后推送到它:

/* Creating Hotfix Branch */
createBranchCommand = git.branchCreate();
createBranchCommand.setName("hotfix_" + releaseVersion);
createBranchCommand.setUpstreamMode(SetupUpstreamMode.SET_UPSTREAM);
createBranchCommand.setStartPoint("origin/" + "hotfix_" + releaseVersion);
createBranchCommand.setForce(true);
createBranchCommand.call();