forum/git-annex unused not dropping deleted filesgit-annexhttp://git-annex.branchable.com/forum/git-annex_unused_not_dropping_deleted_files/git-annexikiwiki2016-01-29T21:37:35Zcomment 1http://git-annex.branchable.com/forum/git-annex_unused_not_dropping_deleted_files/comment_1_2152cfb09675e46e7492e198dd3ea094/joeyh.name2013-11-27T22:47:37Z2013-09-13T15:34:03Z
The most likely explanation is that you have a branch in git that still contains the deleted file, which will prevent unused from removing it. Try <code>git branch -a</code> to see all branches (a tag could also do it).
comment 2http://git-annex.branchable.com/forum/git-annex_unused_not_dropping_deleted_files/comment_2_97e666dbac9de2a5e688921cba8a42e9/Hamza2013-11-27T22:47:37Z2013-09-13T15:59:29Z
<p>I did not create tags or branches, running returns,</p>
<pre><code>git branch -a
git-annex
* master
synced/git-annex
synced/master
remotes/origin/HEAD -> origin/master
remotes/origin/git-annex
remotes/origin/master
remotes/origin/synced/master
</code></pre>
comment 3http://git-annex.branchable.com/forum/git-annex_unused_not_dropping_deleted_files/comment_3_d7b0e9515bface28f3650b8aa20ec2f4/joeyh.name2013-11-27T22:47:37Z2013-09-13T16:17:39Z
Depending on your git configuration, <code>git annex sync</code> might not be updating certian of these branches, such as remotes/origin/HEAD. You can check the branches out and see which still contains your deleted files.
comment 4http://git-annex.branchable.com/forum/git-annex_unused_not_dropping_deleted_files/comment_4_5816f6cab42e27e724e735368f693b09/Hamza2013-11-27T22:47:37Z2013-09-13T17:57:38Z
Which one of those branches I can safely delete? this is a central repo all other clients drop their stuff here it does not have any remotes (I did clones it from a client then removed origin section from config.)
comment 5http://git-annex.branchable.com/forum/git-annex_unused_not_dropping_deleted_files/comment_5_8e97f39225515f0bf8b168dfd6a0efab/joeyh.name2013-11-27T22:47:37Z2013-09-13T18:23:02Z
<p>So this is a bare repository?</p>
<p>It seems to have had an origin at one point; see the remotes/origin/<em> branches. If it no longer has that remote, then of course those branches will not be getting updated, and so will contain the old files and that's why unused won't find them. In that case, you could safely remove the remotes/origin/</em> branches.</p>
comment 6http://git-annex.branchable.com/forum/git-annex_unused_not_dropping_deleted_files/comment_6_bef37f8ec9c337387b79ffd6d56fe425/Hamza2013-11-27T22:47:37Z2013-09-13T18:41:30Z
<p>It is a non bare repo, I am using the following setup,</p>
<p>http://git-annex.branchable.com/forum/Annex_dropping_files/</p>
comment 7http://git-annex.branchable.com/forum/git-annex_unused_not_dropping_deleted_files/comment_7_bff3bcf9f1b7c458afa98cdb18883153/joey2016-01-29T18:26:14Z2016-01-29T18:20:06Z
<p>As someone else ran into a similar case of this, let me explain a little
bit more..</p>
<p><code>git-annex unused</code> finds files that are not used by the currently checked
out branch, or any other branch or tag. This includes remote branches.</p>
<p>This is an important safeguard, because there might be a clone of the
repository that intentionally still has that file checked out, and it
wouldn't be good for <code>git-annex unused</code> to treat such a file as unused.</p>
<p>But if there's an old remote, that's perhaps not getting updated any longer
and has a branch that points to a file, <code>git annex unused</code> won't find that file
as unused.</p>
<p>So, one solution is to use <code>git remote rm</code> to delete the old remote. Or,
otherwise get git to delete the old remote branch that is keeping the file
around.</p>
<p>The other solution is to run something like <code>git annex unused
--used-refspec=+master</code> What this does is only considers the local master
branch as used, and not any other branch or tags. I'd recommend only using
this with caution.</p>
Use --used-refspechttp://git-annex.branchable.com/forum/git-annex_unused_not_dropping_deleted_files/comment_8_7259b8e9616009472ad3a10426f3d8ea/viric2016-01-29T21:37:35Z2016-01-29T21:37:35Z
<p>"joeyh" just helped me on irc, because I had this very same problem. I have git-annex repositories in A, and in external hard disks B, C, D, ...</p>
<p>If I remove a file in A, I mean to 1) free space in A (drop) and 2) this to propagate later to the drives.</p>
<p>No matter what "git annex sync" you do from A, the hard disks in your armchair will keep references to the file in their checkout, so A will refuse to drop the file contents until you run "git annex sync" from <em>each</em> of your external hard disks.</p>
<p>What you need (and what I also needed) was to rule the drop/unused from A alone. You have to use "git annex unused --used-refspec=+master" from A, and that
will only keep into account the contents referenced by your current A master, ignoring the checkouts of B, C, D, ...</p>
<p>The "used-refspec" can even be set up in the git config.</p>