JGit: Checkout a remote branch

前端 未结 4 1544
滥情空心
滥情空心 2020-12-16 10:46

I\'m using JGit to checkout a remote tracking branch.

Git binrepository = cloneCmd.call()

CheckoutCommand checkoutC         


        
4条回答
  •  醉酒成梦
    2020-12-16 10:53

    For whatever reason, the code that robinst posted did not work for me. In particular, the local branch that was created did not track the remote branch. This is what I used that worked for me (using jgit 2.0.0.201206130900-r):

    git.pull().setCredentialsProvider(user).call();
    git.branchCreate().setForce(true).setName(branch).setStartPoint("origin/" + branch).call();
    git.checkout().setName(branch).call();
    

提交回复
热议问题