Skip to content

Instantly share code, notes, and snippets.

@miya2000
Created December 23, 2010 06:23
Show Gist options
  • Save miya2000/752654 to your computer and use it in GitHub Desktop.
Save miya2000/752654 to your computer and use it in GitHub Desktop.
package ttt;
import java.io.File;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.storage.file.FileRepository;
public class JGitTest {
public static void main(String[] args) throws Exception {
String testProjectPath = "C:\\tmp\\jgittest";
File projectDir = new File(testProjectPath);
File gitDir = new File(projectDir, ".git");
Git git = null;
if (!gitDir.exists()) {
git = Git.init().setDirectory(projectDir).call();
}
else {
git = new Git(new FileRepository(gitDir));
}
git.add().addFilepattern(".").call();
git.commit().setMessage("aaaa").call();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment