I fear that while using git annex I will at some point accidentally git add
some small files and not notice it until the only way to fix the problem is to rewrite history. What would be the best way to prevent myself from ever git add
-ing a file into my annex repository instead of git annex add
-ing it?
And secondly, how can I best search in my git annex repository whether I already did this mistake in the past or not? Currently I'm using this which returns everything that's not a symlink or a git submodule:
git ls-files -s | awk ' $1 != 120000 && $1 != 160000 { print $4 }'
I'm not sure if you can prevent 'git add' but you can at least prevent it getting commited with the pre-commit hook. Mine is this:
Based on the above, I'm using this script in the
pre-commit
hook.It gets the staged files and checks if they are links or not. If a file being committed is not a link (maybe it was added with
git add filename
???), the script aborts the commit.