我正在使用JGit签出远程跟踪分支。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?
我试过了。有用。其简单的解决方案。我需要做出改变,承诺并推动远程。我会测试并更新线程。 – Nambi
比我的完整答案。 +1 – VonC
上面的代码不会与git标签一起使用,权限? –