Remove Git-Annex Repository from File Tree

Remove git-annex repository from file tree

Okay, so I stumbled upon some docs for git-annex, and they give two commands that achieve what I wanted to do:

unannex [path ...]

Use this to undo an accidental git annex add command. You can use git annex unannex to move content out of the annex at any point, even if you've already committed it.
This is not the command you should use if you intentionally annexed a file and don't want its contents any more. In that case you should use git annex drop instead, and you can also git rm the file.

uninit

Use this to stop using git annex. It will unannex every file in the repository, and remove all of git-annex's other data, leaving you with a git repository plus the previously annexed files.

I started running git annex uninit, but my god was it slow. It took about 5 minutes to "unannex" just a single file. My filesystem tree is about 200,000 files, so that was just unacceptable.

What I ended up doing was actually surprisingly simple and worked well. I used the cp -rL flags to automatically duplicate the contents of my file tree and reverse all symlinks in the duplicate copy. And it was blazing fast: around 30 seconds for my entire file tree. Only problem was that the file permissions were not retained from my original state, so I needed to run some chmod and chcon commands to fix up the permissions.

This second method worked for me because there were no other symlinks in my schema. If you do have symlinks in your schema beyond those created by git-annex, then my little shortcut probably isn't the right choice for you, and you should consider sticking with just git annex uninit.

Why won't git annex die?

Double-check if you have any hook in your current Git repo

cd /path/to/my/repo/.git/hooks

Check also if git itself is a wrapper script.

Look for the git-annex (which git-annex)executable and remove it

git-annex: remove content of files from special remote that were deleted more than 4 weeks ago

I do not believe that you can do this with git-annex as it stands, based on my reading of the MATCHING OPTIONS in the git-annex man page. Note that there are no options that consider age.

Therefore, I guess that you would have to write a script to use git annex unused to list the unused files, and then compute their age by a search in the git log.

How to delete one of several git-annex replicas?

You need to tell one of your other repositories, that this repository is dead. Git annex sync will propagate this information to all other repositories, so all repositories will eventually now that its data is no longer accessible.

After marking it as dead git annex info should no longer list it and sync it.

For some more information, see here:

https://git-annex.branchable.com/tips/what_to_do_when_you_lose_a_repository/

https://git-annex.branchable.com/git-annex-dead/

List all files in git repo not added by `git annex add`

  1. Use ls-files to list all files in repo.
  2. Use annex find to list all files in annex.
  3. Find the unique entries from the above results
git ls-files > ~/tmp/ls-files.list
git annex find > ~/tmp/annex-find.list
awk 'FNR==NR {a[$0]++; next} !a[$0]' ~/tmp/annex-find.list ~/tmp/ls-files.list


Related Topics



Leave a reply



Submit