アナSustic:
私が使用して指定されたディレクトリからすべてのファイルを追加したいaddFilepattern
gitリポジトリにし、その後の変更をコミットします。私は私が行うときにコミット内のファイルを見ることを期待していますgit show
が、代わりにコミットが存在しますが空です。
これはコードです:
//create target directory for jGit
File targetDirectory = new File("/Users/asusti/jGit/");
if (!targetDirectory.exists()) {
if (targetDirectory.mkdir()) {
System.out.println("jGit directory is created!");
} else {
System.out.println("jGit Directory exists!");
}
}
//create a new Git repository instance
// The Git-object has a static method to initialize a new repository
try (Git git = Git.init()
.setDirectory(targetDirectory)
.call()) {
System.out.println("Created a new repository at " + git.getRepository().getDirectory());
git.add().addFilepattern("/Users/asusti/Downloads").call();
git.commit().setMessage("Added yaml files to the repository.").setAuthor("anas", "[email protected]")
.call();
} catch (IllegalStateException | GitAPIException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Khairyi S:
それを試してみてください
git.add().addFilepattern(".").call();
CommitCommand commit = git.commit();
commit.setMessage("Added yaml files to the repository.").call();
git.push().call();