Search code examples
gitsshremote-accessgit-remote

Git work-tree on other server


I'm trying to deploy a git branch to another server.

I'm using this command line for it: git --work-tree=$TARGET --git-dir=$GIT_DIR checkout -f.

Since I'm running this line on my git server, it's fine to simply use the relative local path for my $GIT_DIR, but since my target is on another server, I'm not sure how to call it.

I tried ssh-user@my-domain.com:/user-root-dir/my-repository/my-repository.git, but it says fatal: Could not switch to 'ssh-user@my-domain.com:/user-root-dir/my-repository/': No such file or directory although the directory structure is correct. I double checked for typos.

What am I doing wrong?


Solution

  • A worktree must be accessible by git using standard filesystem system calls hence it must be mounted as a local FS. Either push your changes over ssh to a remote repo or mount the remote FS using sshfs.