我正在使用 JGit 来检查远程跟踪分支。
Git binrepository = cloneCmd.call()
CheckoutCommand checkoutCmd = binrepository.checkout();
checkoutCmd.setName( "origin/" + branchName);
checkoutCmd.setUpstreamMode(CreateBranchCommand.SetupUpstreamMode.TRACK );
checkoutCmd.setStartPoint( "origin/" + branchName );
Ref ref = checkoutCmd.call();
文件已签出,但 HEAD 未指向分支。以下是git status
输出,
$ git status
# Not currently on any branch.
nothing to commit (working directory clean)
可以在 git 命令行中轻松执行相同的操作,并且可以正常工作,
git checkout -t origin/mybranch
这个JGit怎么做?