I am trying to create a Git repository using objective-git. The documentation is somewhat lacking on how the GT classes work together to create a repository so I'm kind of stuck.
This is what I have working so far:
GTRepository *newRepo = [GTRepository initializeEmptyRepositoryAtFileURL:repoURL error:&error]
I then copy a bunch of files into that directory. I can open then the repo in a Git client and see those files in the working directory. Everything looks good so far. But this is where I'm stuck, what is my next move to actually create a branch and commit those files?
EDIT: I have now gotten the GTIndex from my GTRepository (though, the fileURL property of the index is still nil, so I'm not sure how to generate that file). I iterate through my files, calling addFile:error:
which creates GTIndexEntries in my index. I then call writeTree:
and get back a GTTree that I pass into [repository createCommitWithTree:newTree message:@"Initial Commit" parents:nil updatingReferenceNamed:nil error:&error];
. This returns a valid GTCommit object and no NSError, but I would expect that [repository headReferenceWithError:&error]; would now return a reference to the newly created commit, but it still returns nil. Is there a step I am missing to finalize this commit?
Looks like there's a [GTReference referenceByCreatingReferenceNamed:name]
static method. Here's an example of how you use it.