0

I try to write a file store based on libgit2. Software snapshots should be saved as branches mysoftware and specific versions committed and tagged. Then later I want to checkout the tags to different directories.

When looking at git_checkout_tree, it seems like there is only one working tree for a repository and thus it does not even seem possible to checkout multiple working trees concurrently. Is this correct!?

EDIT:

Additionally, I would like for this thing to work on Windows without the need for cygwin!

abergmeier
  • 13,224
  • 13
  • 64
  • 120
  • possible duplicate of [Multiple working directories with Git?](http://stackoverflow.com/questions/6270193/multiple-working-directories-with-git) – user229044 Mar 07 '14 at 18:31
  • Actually it turned out that using a bare repository was sufficient in my case, since I only want the repo edited by my libgit2 implementation. And utilizing `Tree` and `Index`, this works like a charm. – abergmeier Mar 25 '14 at 10:47

2 Answers2

3

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.

abergmeier
  • 13,224
  • 13
  • 64
  • 120
arrbee
  • 241
  • 1
  • 2
1

Git doesn't support this natively, but you can use git-new-workdir to do it.

user229044
  • 232,980
  • 40
  • 330
  • 338