git-annex/doc/metadata.mdwn
Joey Hess d0fce426c4 pre-commit-annex hook script to automatically extract metadata from lots of types of files
Using the extract(1) program to do the heavy lifting.

Decided to make git-annex run pre-commit-annex when committing. Since
git-annex pre-commit also runs it, it'll be run when git commit is run too,
via the pre-commit hook. This basically gives back the pre-commit hook
that git-annex took away. The implementation avoids repeatedly looking
for the hook script when the assistant is running and committing
repeatedly; only checks if the hook is available once.

To make the script simpler, made git-annex metadata -s field?=value
only set a field when it's not already got a value.

This commit was sponsored by bak.
2014-03-02 20:11:58 -04:00

42 lines
1.9 KiB
Markdown

git-annex allows you to store arbitrary metadata about files stored in the
git-annex repository. The metadata is stored in the `git-annex` branch, and
so is automatically kept in sync with the rest of git-annex's state, such
as [[location_tracking]] information.
Some of the things you can do with metadata include:
* Using `git annex metadata file` to show all
the metadata associated with a file.
* [[tips/metadata_driven_views]]
* Limiting the files git-annex commands act on to those with
or without particular metadata.
For example `git annex find --metadata tag=foo --or --metadata tag=bar`
* Using it in [[preferred_content]] expressions.
For example "tag=important or not author=me"
Each file (actually the underlying key) can have any number of metadata
fields, which each can have any number of values. For example, to tag
files, the `tag` field is typically used, with values set to each tag that
applies to the file.
The field names are limited to alphanumerics (and `[_-.]`), and are case
insensitive. The metadata values can contain absolutely anything you
like -- but you're recommended to keep it simple and reasonably short.
Here are some recommended metadata fields to use:
* `tag` - With each tag being a different value.
* `year`, `month` - When this particular version of the file came into
being.
To make git-annex automatically set the year and month when adding files,
run `git config annex.genmetadata true`. Also, see
[[tips/automatically_adding_metadata]].
git-annex's metadata can be updated in a distributed fashion. For example,
two users, each with their own clone of a repository, can set and unset
metadata at the same time, even for the same field of the same file.
When they push their changes, `git annex merge` will combine their
metadata changes in a consistent and (probably) intuitive way.
See [[the metadata design page|design/metadata]] for more details.