So far in this walkthrough, git-annex has been used with a remote repository on a USB drive. But it can also be used with a git remote that is truly remote, a host accessed by ssh.
Say you have a desktop on the same network as your laptop and want to clone the laptop's annex to it:
desktop$ git clone ssh://mylaptop/home/me/annex ~/annex
desktop$ cd ~/annex
desktop$ git annex init "my desktop"
Now you can get files and they will be transferred (using rsync
via ssh
):
desktop$ git annex get my_cool_big_file
get my_cool_big_file (getting UUID for origin...) (from origin...)
SHA256-s86050597--6ae2688bc533437766a48aa19f2c06be14d1bab9c70b468af445d4f07b65f41e 100% 2159 2.1KB/s 00:00
ok
When you drop files, git-annex will ssh over to the remote and make sure the file's content is still there before removing it locally:
desktop$ git annex drop my_cool_big_file
drop my_cool_big_file (checking origin..) ok
Note that normally git-annex prefers to use non-ssh remotes, like
a USB drive, before ssh remotes. They are assumed to be faster/cheaper to
access, if available. There is a annex-cost setting you can configure in
.git/config
to adjust which repositories it prefers. See
the man page for details.
Also, note that you need full shell access for this to work -- git-annex needs to be able to ssh in and run commands. Or at least, your shell needs to be able to run the git-annex-shell command.
For details on setting up ssh remotes, see the centralized git repository tutorial.
Found the problem:
One should never use ~ in such path:
WRONG export PATH=~/somedir:$PATH
Instead one should use $HOME:
GOOD export PATH=$HOME/somedir:$PATH
Can I surpress the message that shell failed with status 255 when a repo is unavailible? I've got two repos pointing to one machine - either via vpn or local lan and I keep getting erros if one is unavailible:
ssh: connect to host 10.9.0.1 port 39882: No route to host Command ssh ["-S","/home/pielgrzym/annex/.git/annex/ssh/nas","-o","ControlMaster=auto","-o","ControlPersist=yes","nas","git-annex-shell 'configlist' '/~/annex'"] failed; exit code 255
Hi,
I have a same 'git-annex-shell command not found' problem as above. I've installed git annex via cabal into my ~/.haskell_bin directory. Then I've added this dir both to ~/.bashrc and ~/.zshrc. I can run git annex or 'git annex-shell' and everything is fine. My guess is that haskell is trying to spawn git-annex-shell with some current $PATH unaware shell like dash maybe?
I've fixed this behavior by using a really ugly hack - I've symlinked ~/.haskell_bin/git-annex-shell to /usr/bin/git-annex-shell on all my machines and the problem is gone. Somehow haskell (or whatever is trying to call git-annex-shell) is unaware of path modifications from .bashrc/.zshrc
Here is the path modification I've used:
export PATH=~/.haskell_bin:$PATH
Hi,
It was already installed in PATH. In fact, I can call it from the command line, and it is recognized (e.g. calling 'git-annex-shell' gives me 'git-annex-shell: bad parameters'). However, every time I do a 'git annex whereis' or 'git annex get file --from repo', it gives me the following error:
bash: git-annex-shell: command not found Command ssh ["-S","/Users/username/annex/.git/annex/ssh/username@example.edu","-o","ControlMaster=auto","-o","ControlPersist=yes","username@example.edu","git-annex-shell 'configlist' '/~/annex'"] failed; exit code 127
I tried to run this ssh command, but it gives me the same 'command not found' error. It seems that the problem is with the ssh repo? The ssh repo has a git-annex-shell working and installed in PATH.
git-annex-shell needs to be installed in the
PATH
on any host that will hold annexed files.If you installed with cabal, it might be
.cabal/bin/
. Whereever it was installed to is apparently not on the PATH that is set when you ssh into that host.Hi,
I guess the problem is with git-annex-shell. I tried to do 'git annex get file --from name_ssh_repo', and I got the following:
bash: git-annex-shell: command not found; failed; exit code 127
The same thing happens if I try to do 'git annex whereis'
git-annex-shell is indeed installed. How can I make my shell recognize this command?
Thanks a lot!
git annex whereis
on the file and see where it says it is.Thanks for the quick replay!
I already did 'git annex sync', but it didn't work. The steps were: 'git clone ssh...', then 'cd annex', then 'git annex init "laptop"'
After that, I did a 'git annex sync', and tried to get the file, but nothing happens. That's why I found it weird. Any other thing that might have happened?
Thanks again!
Hi,
I could successfully clone my ssh repo's annex to my laptop, following these instructions. I'm also able to sync the repositories (laptop and ssh) when I commit new files in the ssh repo.
However, every time I try to get files from the ssh repo (using 'git annex get some_file'), nothing happens. Do you know what can be happening?
Thanks!
When
git annex get
does nothing, it's because it doesn't know a place to get the file from.This can happen if the
git-annex
branch has not propigated from the place where the file was added. For example, if on the laptop you had rungit pull ssh master
, that would only pull the master branch, not the git-annex branch.An easy way to ensure the git-annex branch is kept in sync is to run
git annex sync
@Michael, the standalone tarball is really meant to run the git-annex assistant. The first time "git annex webapp" is run, it will set up the ssh wrapper for you.
I have updated the wrapper to work when ssh is not configured to force a key to run a command.
Thanks Matthias, I fought with this as well, this was the tip I needed to move on. I'm using the Linux standalone, and I had 2 issues getting everything to work without getting git-annex-shell errors.