I'm trying to automate syncing of two repos A and B. My goal is to run git annex sync
from A and have the working copy of B updated automatically. According to the manual page, git annex merge
should to the trick. It works just fine when I run it manually in B, but not when I run it from the post-receive hook, as suggested in the manual page.
Here is a test script that illustrates the issue: https://gist.github.com/anonymous/6197019
The output I get:
[...]
file1 exists after manual git annex merge
[...]
file2 does not exist after git annex merge in post-receive
From the output I can see that git annex merge
is run on the remote end, and seems to do it's thing (file2
is added):
remote: merge git-annex (merging synced/git-annex into git-annex...)
remote: ok
remote: merge synced/master Updating 6e5bfba..0dcbcfd
remote: Fast-forward
remote: file2 | 1 +
remote: 1 file changed, 1 insertion(+)
remote: create mode 120000 file2
remote:
remote: ok
However, the working copy in B does not have the file file2
. Even worse, git status
in B shows the file as deleted:
# On branch master
# Your branch is ahead of 'origin/master' by 2 commits.
#
# Changes not staged for commit:
# (use "git add/rm <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# deleted: file2
#
no changes added to commit (use "git add" and/or "git commit -a")
So when running git annex sync
from B now, the file will be deleted from A as well, which is not what I expected.
This is on Ubuntu 12.04, using the precompiled git-annex tarball (amd64).
What am I doing wrong?
I'm trying to achieve USB backup with files visible but can't make the post-recieve or post-update hooks have any effect. The filesystem is vfat so there are some issues with mounting defaults and executables (do the hooks have to be executable?) but regardless of mount options no dice.
git-annex merge
at the cli works perfectly. I havent been bitten by files being deleted and propagated though.Manually merging ruins my "late for work need to bring data but to tired to think properly" use case.
Having just set up http://annex.debconf.org which uses a git hook to run
git annex merge
, I can say that the main problems you are likely to run into are:GIT_DIR
set to a strange value (in my case, it was set to "."), which is not the actual .git directory location. Unsetting it fixes that.I don't know about how to get git hooks to work on FAT filesystems though. Hooks have to be executable, and most systems probably don't mount such filesystems with executability allowed.
Thanks joey, that's exactly what was happening.
Just to repeat it here, if anyone else runs into the same problem, your post-receive hook has to look like this:
An easier way to set this up is available now, see https://git-annex.branchable.com/tips/making_a_remote_repo_update_when_changes_are_pushed_to_it/