一、JGit有效的链接
JGit使用ssh及http(s)2中方式,链接git仓库:https://www.codeaffine.com/2014/12/09/jgit-authentication/
二、切换分支遇到的问题
1.org.eclipse.jgit.api.errors.NoHeadException: Cannot checkout from unborn branch
2.pull权限不够
git.pull().call
问题:
org.eclipse.jgit.api.errors.TransportException: http://igit.xxxx.com/xxx/platform/xxxx: Authentication is required but no CredentialsProvider has been registered
解决办法:设置用户名和密码
增加方法:setCredentialsProvider(usernamePasswordCredentialsProvider)
即:git.pull().setCredentialsProvider(usernamePasswordCredentialsProvider).call();
3.修改密码后重新clone代码权限不够(window7操作系统)
原因:git客户端之前操作的原因
解决:重置git的配置文件
命令:git config --system --unset credential.helper