JGit: Checkout a remote branch

前端 未结 4 1545
滥情空心
滥情空心 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:01

    As shown in the code of CheckoutCommand, you need to set the boolean createBranch to true in order to create a local branch.

    You can see an example in CheckoutCommandTest - testCreateBranchOnCheckout()

    @Test
    public void testCreateBranchOnCheckout() throws Exception {
      git.checkout().setCreateBranch(true).setName("test2").call();
      assertNotNull(db.getRef("test2"));
    }
    

提交回复
热议问题