JGit: Checkout a remote branch

前端 未结 4 1538
滥情空心
滥情空心 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 11:03

    you also can just like this

    git.checkout().setName(remoteBranch).setForce(true).call();
                    logger.info("Checkout to remote branch:" + remoteBranch);
                    git.branchCreate() 
                       .setName(branchName)
                       .setUpstreamMode(SetupUpstreamMode.SET_UPSTREAM)
                       .setStartPoint(remoteBranch)
                       .setForce(true)
                       .call(); 
                    logger.info("create new locale branch:" + branchName + "set_upstream with:" + remoteBranch);
                    git.checkout().setName(branchName).setForce(true).call();
                    logger.info("Checkout to locale branch:" + branchName);
    

提交回复
热议问题