i am working on a project where i need to copy many subsets of files stored in a single annex repo to separate folders outside of the annex repo (each subset to a separate folder).
to select each subset, i'm using git annex metadata --set <tag>=<value> <path>
.
what i would like to do, ideally, is to leverage each git annex view <tag>=<value>
invocation to directly check out the view's files to a specific directory outside of the annex repo.
the use case is basically the "Copying objects" strategy of the syncthing special remote discussion, although rather than having the 'directory' special remote contain files in that remote's specific layout, i would like them to be checked out simply with their original file names.
say i have these files in my main annex repo:
a.pdf (metadata: topic=haskell)
b.pdf (metadata: topic=haskell)
c.pdf (metadata: topic=iojs)
d.pdf (metadata: topic=python)
e.pdf (metadata: topic=haskell)
if i issue git annex view topic=haskell
, i have the files i want in my annex' root:
a.pdf
b.pdf
e.pdf
obviously i could then simply run rsync --exclude .git -aL --delete . ../other/dir
, which is totally fine, but maybe i'm just blindly missing something obvious and i could simply use something like git annex --work-tree=../other/dir view topic=haskell
and see a.pdf
, b.pdf
and e.pdf
appear in the target directory (i don't need any metadata in that directory, so only the plain files and no .git folder for a remote is fine).
Well, you can certianly use --work-tree with git-annex. As a global git option, it has to be passed after the "git" and before the "annex". However, since the view is constructed by making symlinks to the annexed content, the result will be a directory full of symlinks, rather than the contents of the files. Also, it'll still update the repo to think it has this view checked out, with confusing results.
rsync seems to be a perfectly good way to do what you want, if you want to have copies of the files.
Or, you might consider making a shared clone of the git repo wherever you want that tree of files, and checking out the desired view in the clone. In a shared clone with a recent version of git-annex, running
git annex get
will quickly hard-link the files from the main repo (when possible).I am not sure whether it would help, but to show views of my git-annex repositories without messing with the current working directory, I generally use git-new-workdir https://github.com/git/git/blob/master/contrib/workdir/git-new-workdir
It allows to checkout a separate branch in another directory. The new directory's .git directory contains symbolic links to the parent one, making sure that changes in the new work dir are propagated to the parent one.
Hope that helps.