The git_checkout_opts
structure in libgit2
contains a target_directory
option that will allow git_checkout_tree()
to write to a different directory instead of using the default working tree for the repository. This would allow you to custom build a solution with libgit2 that maintained multiple checked out copies.
Without using that option, a libgit2
git_repository
object expects there will be just one working directory and looks to the core.worktree
config option if it isn't the "natural" working directory for the repository.
The git-new-workdir
tricks with symlinks in the .git
directory don't work great with libgit2
right now, I'm afraid, and particularly doesn't work well on Windows. I'd love to see this addressed, but it isn't too high on my priority list.