我正在尝试使用JGit处理HEAD提交:valbuilder=newFileRepositoryBuilder()valrepo=builder.setGitDir(newFile("/www/test-repo")).readEnvironment().findGitDir().build()valwalk:RevWalk=newRevWalk(repo,100)valhead:ObjectId=repo.resolve(Constants.HEAD)valheadCommit:RevCommit=walk.parseCommit(head)我发现它可以很好地打开repo,但是hea
我正在尝试使用JGit处理HEAD提交:valbuilder=newFileRepositoryBuilder()valrepo=builder.setGitDir(newFile("/www/test-repo")).readEnvironment().findGitDir().build()valwalk:RevWalk=newRevWalk(repo,100)valhead:ObjectId=repo.resolve(Constants.HEAD)valheadCommit:RevCommit=walk.parseCommit(head)我发现它可以很好地打开repo,但是hea
我一直在开发一款基于Java的产品,该产品将集成Git功能。使用其中一项Git功能,我通过暂存然后在一次提交中提交它们,将10多个文件添加到Git存储库中。上述过程的逆过程是否可行?即查找作为提交一部分提交的文件列表。我在git.log()命令的帮助下获得了提交,但我不确定如何获取提交的文件列表。示例代码:Gitgit=(...);Iterablelogs=git.log().call();for(RevCommitcommit:logs){StringcommitID=commit.getName();if(commitID!=null&&!commitID.isEmpty()){T
我想使用JGit显示head修订版的所有文件和文件夹的列表。我可以使用TreeWalk列出所有文件,但这不会列出文件夹。这是我目前所拥有的:publicclassMainClass{publicstaticvoidmain(String[]args)throwsIOException{FileRepositoryBuilderbuilder=newFileRepositoryBuilder();Repositoryrepository=builder.setGitDir(newFile("C:\\temp\\git\\.git")).readEnvironment().findGitD
我如何在JGit中merge?假设我想mergemaster和foo分支,我该怎么做? 最佳答案 要merge,您可以在CheckoutCommand之后使用MergeCommand(在包org.eclipse.jgit.api中)。给大家举个例子,因为Jgit确实缺少例子:Gitgit=...//yougetitthroughaCloneCommand,InitCommand//orthroughthefilesystemCheckoutCommandcoCmd=git.checkout();//Commandsarepartof
RevCommit有一个getCommitTime()方法,但它返回一个int并且没有作者时间。如何从RevCommit中获取作者和提交日期? 最佳答案 像这样:RevCommitcommit=...;PersonIdentauthorIdent=commit.getAuthorIdent();DateauthorDate=authorIdent.getWhen();TimeZoneauthorTimeZone=authorIdent.getTimeZone();PersonIdentcommitterIdent=commit.ge
我正在使用JGit访问远程Git仓库,我需要使用SSH为了它。JGit使用JSch提供安全访问。但是,我不确定如何为JGit设置key文件和已知主机文件。我试过的如下。创建了SshSessionFactory的自定义配置,通过子类化使用JSchConfigSessionFactory:publicclassCustomJschConfigSessionFactoryextendsJschConfigSessionFactory{@Overrideprotectedvoidconfigure(OpenSshConfig.Hosthost,Sessionsession){session.s
我该怎么办gitclone--depth1...使用JGIT库? 最佳答案 你不能,JGit还不支持clientside上的浅克隆(虽然它在serverside上执行)。 关于java-使用JGIT进行浅克隆,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/11475263/
我在玩JGit,我可以成功地从某个存储库中删除一个远程服务器(gitremotermorigin),我该怎么做gitremoteaddoriginhttp://github.com/用户/repo?要删除我执行以下操作:StoredConfigconfig=git.getRepository().getConfig();config.unsetSection("remote","origin");config.save();但是没有像#setSection(String,String)这样的选项。提前致谢。 最佳答案 管理它以这种方
在同一台机器上使用githubforwindows,使用相同的凭据工作正常。可以pull/克隆。但是在同一台机器上作为windows服务安装的teamcity返回以下错误Listremoterefsfailed:org.eclipse.jgit.errors.TransportException:https://github.com/my-private-repo.git:notauthorized 最佳答案 在teamcity中,在项目VCSRoot中,如果认证方式是基于ssh公钥/私钥,那么fetchURL应该像git@gith