git-annex/doc/walkthrough/automatically_managing_content.mdwn
Joey Hess 984c9fc052 remove optimize subcommand; use --auto instead
get, drop: Added --auto option, which decides whether to get/drop content
as needed to work toward the configured numcopies.

The problem with bundling it up in optimize was that I then found I wanted
to run an optmize that did not drop files, only got them. Considered adding
a --only-get switch to it, but that seemed wrong. Instead, let's make
existing subcommands optionally smarter.

Note that the only actual difference between drop and drop --auto is that
the latter does not even try to drop a file if it knows of not enough
copies, and does not print any error messages about files it was unable to
drop.

It might be nice to make get avoid asking git for attributes when not in
auto mode. For now it always asks for attributes.
2011-09-15 13:30:04 -04:00

38 lines
1.5 KiB
Markdown

Once you have multiple repositories, and have perhaps configured numcopies,
any given file can have many more copies than is needed, or perhaps fewer
than you would like. How to manage this?
The whereis subcommand can be used to see how many copies of a file are known,
but then you have to decide what to get or drop. In this example, there
are rather too many copies of `other_file` and perhaps not enough of the
other file.
# cd /media/usbdrive
# git annex whereis
whereis my_cool_big_file (1 copy)
0c443de8-e644-11df-acbf-f7cd7ca6210d -- laptop
whereis other_file (3 copies)
0c443de8-e644-11df-acbf-f7cd7ca6210d -- laptop
62b39bbe-4149-11e0-af01-bb89245a1e61 -- usb drive <-- here
7570b02e-15e9-11e0-adf0-9f3f94cb2eaa -- backup drive
What would be handy is some automated versions of get and drop, that only
get a file if there are not yet enough copies of it, or only drop a file
if there are too many copies. Well, these exist, just use the --auto
option.
# git annex get --auto --numcopies=2
get my_cool_big_file (from laptop...) ok
# git annex drop --auto --numcopies=2
drop other_file ok
With two quick commands, git-annex was able to decide for you how to
work toward having two copies of your files.
# git annex whereis
whereis my_cool_big_file (2 copies)
0c443de8-e644-11df-acbf-f7cd7ca6210d -- laptop
62b39bbe-4149-11e0-af01-bb89245a1e61 -- usb drive <-- here
whereis other_file (2 copies)
0c443de8-e644-11df-acbf-f7cd7ca6210d -- laptop
7570b02e-15e9-11e0-adf0-9f3f94cb2eaa -- backup drive