I'm cloning a remote repository and want to checkout several branches to interoperate with them (without applying changes to the working directory).
So I clone the repository:
CloneCommand clone = Git.cloneRepository();
clone.setURI(project.getUrl());
clone.setDirectory(new File(RepositoryHandlerHelper
.getFilePath(project)));
clone.setCredentialsProvider(getCredentials());
clone.setCloneAllBranches(true);
clone.call();
And that works. Now I create the remote branches on my local harddrive (in a loop):
git.branchCreate().setName(currentBranchToBuild)
.setUpstreamMode(SetupUpstreamMode.TRACK)
.call();
Which works as well. I'm not sure this is necessary though.. After that I try to checkout each branch:
git.checkout().setName(currentBranchToBuild).call();
I'm sure right branch name is submitted to setName()
. No Exception is thrown but the command does not seem to take any effect on my working directory.
Am I missing something here?