Hi,
I store lots of books under annex and every once in a while one of them gets updated and I don't really want to keep the old version. I know about the unused
subcommand but it makes a bit difficult to identify what I would be dropping. I mean, at the point in time when I'm replacing a file I already know I don't want to keep in the annex, maybe there is a method that directly referrs to that file instead of globally garbage collecting obscurely named files. Now, this is what comes to my mind:
Alternative a
- git-annex drop f
- git rm f
- mv new-f f
- git-annex add f
Alternative b
- git-annex unlock f
- mv new-f f
- git-annex add f
- git commit -am blah
- git checkout HEAD^
- git-annex drop f
- git checkout master
As you can see neither option is that pretty. Is there any way to say 'drop f in revision r' or something similar?
Thank you!
Your alternative B does not actually remove the old version of the file, because git-annex unlock keeps a copy in .git/annex/objects (except when using v6 mode with annex.thin).
Alternative A is fine, if you just want to remove the old version of the file from the local repository. Other clones of the repository may still have the content of that file though.
I use alternative A fairly frequently in my own repositories, and then sometimes followup with
git annex unused
in clones and dropping all unused files.Is there also a straight forward way to drop all versions of a specific file?
In option 1, I always have to drop the file right away. In my use case it makes more sense to drop (all) older versions of a specific file from time to time.
Typically I want to keep old versions (of other files), therefore I can't use drop unused. But for some specific files, I want to get rid of the history at some point in time (e.g., after the project they belong to is finished).
Alternatively, is there a way to get all prior keys a specific file once pointed to? Then I could drop all these keys.
@mario: AFAIK there's no built-in way to drop selected|all old versions of a file.
Some Context:
My proposal above would facilitate this (kinda), e.g. like this:
The
--historical
is not implemented, so you currently have two options:1. Checking out each relevant commit, then drop content from there
2. Parsing the log to find the relevant keys to drop
I would also love a git-annex-native way to delete all old versions of a file reliably. I think option 2 above and/or the new view feature I proposed would be very helpful. 👍
@mario interesting question..
You could use
git log --raw
to list old versions of the file, and then usegit show
to find the git-annex key.Doable, but would take quite a lot of bother to script. I think it would be a good enhancement to git-annex to add a command to list keys for old versions of files.