java - Checking out a Git repository by branch or commit ID using JGit -


i cloning repositories jgit using following:

git.clonerepository()     .seturi(uri)     .setdirectory(createtempdir())     .setbranchestoclone(singleton("refs/heads/" + branch))     .setbranch("refs/heads/" + branch)     .call(); 

however allow branch commit id. how implement this?

while cloning git repository, can specify branches (or more references) cloned. not specific jgit applies cli git.

a remote repository can queried available references along commit ids, arbitrary commit id cannot cloned.

with jgit, lsremotecommand can used obtain available references without downloading respective history. or can specify pre-known reference clonecommand in order clone given reference along history.

if performance , bandwidth aren't issue, could, of course, clone repository references (clonecommand.setcloneallbranches( true )) , once available locally, check out desired commit.


Comments

Popular posts from this blog

python - Selenium remoteWebDriver (& SauceLabs) Firefox moseMoveTo action exception -

html - How to custom Bootstrap grid height? -

transpose - Maple isnt executing function but prints function term -