I am trying to remove a remote branch called test
. I don't get any errors while running this code but the remote branch is not getting removed.
'ans' is the destination including the branch id.
This code worked for me when I used the full branch. but I must have changed something because it doesnt work any more.
git.branchDelete().setBranchNames(ans).setForce(true).call();
RefSpec refSpec = new RefSpec()
.setSource(null)
.setDestination("refs/remotes/origin/test");
git.push().setRefSpecs(refSpec).setRemote("origin").call();
Assuming that 'ans' is the full branch name of the local branch e.g. refs/heads/test
the branchDelete()
code looks ok.
But the destination of the ref spec that is pased to the push command should denote the name of the branch as it is referenced on the remote end. In this case refs/heads/test
RefSpec refSpec = new RefSpec().setSource(null).setDestination("refs/heads/test");
or in short
RefSpec refSpec = new RefSpec(":refs/heads/test");