I am developing an application which uses Git as a database. My current approach is to call out to the git
shell command to construct a new commit whenever the application changes something. This is very simple, but a big disadvantage is that it does not allow any concurrent writes to the database: two threads cannot construct a commit simultaneously, because there is a single HEAD
, a single index
, and a single working copy.
However, since commits, trees, and blobs are all content-addressed, I think it should be possible to construct all of these concurrently. What would be the recommended approach for this? Perhaps:
- command line flags to
git add
,git commit
, etc., which explicitly specify a differentHEAD
andindex
file to use. As far as I can see, such things do not exist. - using git plumbing commands for all operations. However, I am not an expert with them and am not totally sure which are thread-safe.
- a Git service, to which one can connect a la traditional database connections, which would provide transactional, concurrent access to a Git repository. As far as I can see, such a thing does not exist. I have considered writing one.
- giving up and doing a
git clone
to get an entirely new working copy for each concurrent user. This is inordinately expensive.