jGit으로 복제본을 복제하는 방법을 여러 번 시도했습니다 (작동 함). 그런 다음 저장소에 일부 보관 파일을 작성하고 모두 (git add *
, git add -A
또는 이와 비슷한 내용)를 추가하려고 시도했지만 작동하지 않습니다. 단순 파일은 준비 영역에 추가되지 않습니다.jGit - 모든 파일을 준비 영역에 추가하는 방법
내 코드는 다음과 같다 : 내가 잘못 뭐하는 거지
FileRepositoryBuilder builder = new FileRepositoryBuilder();
Repository repository = builder.setGitDir(new File(folder))
.readEnvironment().findGitDir().setup().build();
CloneCommand clone = Git.cloneRepository();
clone.setBare(false).setCloneAllBranches(true);
clone.setDirectory(f).setURI("[email protected]:test.git");
try {
clone.call();
} catch (GitAPIException e) {
e.printStackTrace();
}
Files.write("testing it...", new File(folder + "/test2.txt"),
Charsets.UTF_8);
Git g = new Git(repository);
g.add().addFilepattern("*").call();
? 감사합니다. . AddCommandTest.java
다음 JGit repo에서 AddCommand의 시험 보는이를 디버깅하는
Exception in thread "main" org.eclipse.jgit.errors.NoWorkTreeException: Bare Repository has neither a working tree, nor an index
at org.eclipse.jgit.lib.Repository.getIndexFile(Repository.java:850)
at org.eclipse.jgit.dircache.DirCache.lock(DirCache.java:264)
at org.eclipse.jgit.lib.Repository.lockDirCache(Repository.java:906)
at org.eclipse.jgit.api.AddCommand.call(AddCommand.java:138)
at net.ciphersec.git.GitTests.main(GitTests.java:110)
감사하지만 예외가 있습니다. – caarlos0
@ caarlos0 답변 편집 됨 – VonC
하지만 비 (非) 베어 리포 지 토리로 복제합니다 ... 나는 그것을하기로되어있는 것을 undestand하지 않습니다 ... – caarlos0