Back to post index

Moving to non-bare git-annex repos on my file server
Tags: [git-annex] [capablanca]
Published: 06 Jul 2017 09:22

I have more than 20 git-annex repos. Previously, all file content was stored in bare git repos on capablanca under the directory /archive/annex/, like so:

/archive/annex/documents.git/
/archive/annex/ripped_cds.git/
/archive/annex/ripped_movies.git/
/archive/annex/cameras.git/
...

This was problematic though because I recently installed Kodi on a Raspberry Pi 3 and hooked it up to my TV - I wanted to serve DVD rips from my file server and watch them, but serving bare git-annex repos doesn’t work. Unfortunately bare git repos are only useful to git as there is no GIT_WORK_TREE.

I decided to fix this by storing all git-annex repos non-bare in a new /archive/library/ directory. This was a bit of work because I also performed git-annex remote clean up to deal with dead remotes (from my initial experimenting with git-annex).

The work flow was as follows. To not lose extra information like added urls, I couldn’t simply do a git annex uninit followed by a reinitialization. I had to move all files to the new /archive/library/ repo, mark all other old remotes as dead, and then call forget:

[jwm@capablanca /archive/library]$ git clone /archive/annex/ripped_movies.git 
[jwm@capablanca /archive/library]$ cd ripped_movies/
[jwm@capablanca /archive/library/ripped_movies]$ git annex init 'capablanca:archive/library'
[jwm@capablanca /archive/library/ripped_movies]$ git annex move --to=here .

[jwm@capablanca /archive/library/ripped_movies]$ git annex dead 'capablanca:archive/annex'
[jwm@capablanca /archive/library/ripped_movies]$ git annex forget --drop-dead --force

A bunch of deads and drop-deads later, all obsolete annex remotes are gone:

[jwm@capablanca /archive/library/ripped_movies]$ git annex info
repository mode: indirect
trusted repositories: 0
semitrusted repositories: 2
	06824ed1-5267-4820-ab00-c4c756234c47 -- magnus
	82685d09-4a62-45b5-8106-6765bf78c6ab -- capablanca:/archive/library [here]

The essential part to making the full non-bare git-annex repo work with other non-bare checkouts was to set:

git config --local receive.denyCurrentBranch updateInstead

on each /archive/library/ repo. This means that if I attempt to git push to /archive/library/ripped_movies/ it will work (as long as the receiving repo is clean) instead of complaining that you are pushing to a non-bare repo.