Commit a String with JGit
java, jgit
Solution
I think there is no other way to commit any data than using the CommitCommand (except merging or such operations that are very specific).
So, yeah, you should make any change in your file and then add it and commit it (using the AddCommand and CommitCommand from the API).
Problem
A JGit-beginner-question: I use JGit to read a file (BLOB) from a repository and manipulate its content. After that, I want to write the new content with the same filename back to the repository as a new commit. But how can I commit the new content with JGit? My pseudo-code: ``` String gitUrl = "path/to/repository/.git"; Repository repository = new FileRepository(gitUrl); String filename = "test/seppl.txt"; blobId = getIdOf(filename); ObjectLoader object = repository.open(blobId, Constants.OBJ_BLOB); ObjectStream is = object.openStream(); String newContent = processStream(is); // How to commit the newContent in filename? ``` Do I have to write the `newContent` into a file and commit this file with the AddCommand and CommitCommand? Or can I write the String "on-the-fly" into the repository under the same filename? Is there anywhere in the web an example how to make a commit with JGit?