Does anyone know of a Git library for C# that allows client code to add & modify repository files in memory? I have a bare repository that I would like to make additions and modifications to pragmatically. Because it is a bare repository I do not want to write files to the file system. Does something like this exists?
Thanks!
GitSharp exposes a
Create()overload on itsBlobtype which allows a direct write to the Git Object database without the need for an intermediate file in a Working Directory.The unit test below (slightly patched from BlobTests.cs) demonstrates such feature:
EDIT:
You might also be willing to take a look at NGit. It’s an automated port of JGit to .Net. Contrarily to GitSharp, it is still maintained.
The
ObjectInserter(see here) looks like something promising.Note: If you’re willing to use Git as an object database, by directly writing objects without the Commit dance, make sure to create a reference (in
.git/refs) to prevent them from being pruned upon agit gclaunch.Note 2: Git objects are read only, so you won’t be able to “modify” a
Blob. However, if you created a reference pointing at it, you can create a new “updated”Blob, and change the target of the reference to point at the new “version”.