2012-10-16 3 views
1

디렉토리를 만들고 javagit 라이브러리를 사용하여 자식 저장소로 초기화하려고합니다.자바 자식 라이브러리를 사용하여 자식 저장소 초기화 시도

repositoryDirectory = FileUtilities.createTempDirectory("C:/Madhu/ReleaseManagerRepo/Demo_gitRepository"); 
System.out.println("Git Repository Location : " + repositoryDirectory.getAbsolutePath()); 
//get the instance of the dotGit Object 
dotGit = DotGit.getInstance(repositoryDirectory); 
System.out.println("DotGit==========="+dotGit.toString()); 
//Initialize the repository ,similar to git init 
dotGit.init(); 

을 나는 디렉토리가 생성되는 것을 볼 수 있습니다 다음은 내가 사용하고 코드 조각입니다. dotGit.init()가 실행 된 후, 코드에 지정된 디렉토리 아래에 .git (명령 행에서 명령 git init을 실행할 때 얻을 수 있습니다.) 디렉토리가 표시되지 않습니다.

내 두 번째 질문은 내 코드에서 파일을 만들고 그 파일을 git 리포지토리에 추가하려고합니다.

File file = FileUtilities.createFile(repositoryDirectory, "README", "First file in the git repository"); 

//get the current working tree from the git repository 
WorkingTree wt = dotGit.getWorkingTree(); 
GitAddResponse ar = wt.add(); 
wt.commitAll("First commit to the git repository"); 

나는 다음과 같이 예외를 받고 있어요 : 내 경로 환경 변수에 자식/빈을 추가 한

Exception in thread "main" java.io.IOException: 020100: Unable to start sub-process. 
    at edu.nyu.cs.javagit.client.cli.ProcessUtilities.startProcess(ProcessUtilities.java:50) 
    at edu.nyu.cs.javagit.client.cli.ProcessUtilities.runCommand(ProcessUtilities.java:141) 
    at edu.nyu.cs.javagit.client.cli.CliGitAdd.add(CliGitAdd.java:49) 
    at edu.nyu.cs.javagit.api.commands.GitAdd.add(GitAdd.java:67) 
    at edu.nyu.cs.javagit.api.GitFileSystemObject.add(GitFileSystemObject.java:185) 
    at edu.nyu.cs.javagit.api.WorkingTree.add(WorkingTree.java:130) 
    at javagit.JavaGitDemo.main(JavaGitDemo.java:41) 
Caused by: java.io.IOException: CreateProcess: git add C:\Madhu\ReleaseManagerRepo\Demo_gitRepository\README error=2 
    at java.lang.ProcessImpl.create(Native Method) 
    at java.lang.ProcessImpl.<init>(Unknown Source) 
    at java.lang.ProcessImpl.start(Unknown Source) 
    at java.lang.ProcessBuilder.start(Unknown Source) 
    at edu.nyu.cs.javagit.client.cli.ProcessUtilities.startProcess(ProcessUtilities.java:48) 
    ... 6 more 

아래는 동일한에 대한 코드입니다. 그러나 나는 여전히 같은 예외를 보았다. 내가 다른 것에서 누락 된 것이 확실하지 않습니다.

하시기 바랍니다.

감사합니다. Madhusudhan.

답변

1

죽은 글 게시하지만 시스템 환경 변수에 자식 경로를 추가하여 방금 문제를 해결했습니다. - article