Reputation: 139
The CloneRepository command seems to ignore the setBranch parameter if you aren't doing a checkout. Is there a way to specify the branch ( instead of the master )? I don't want to checkout the entire branch but I want to add a file to that branch ( add, commit, and push )
Upvotes: 2
Views: 2993
Reputation: 15872
This works for me when I use the existing snippet for cloning from the jgit-cookbook and only add the following at line 33:
.setBranch("email")
After the snippet is executed, the local clone in the temporary directory has the given branch checked out.
Another option might be to use org.eclipse.jgit.storage.dfs.InMemoryRepository
to clone a Git repo in-memory and work from there.
Upvotes: 2