The only difference I could think of is that with the ssh already down there is no tty and git is trying to access it for some reason or another. So I worked it around by using script
(1). The resulting invocation is somewhat insane, but it works:
nohup script -qec "/path/to/git/script.sh args" /dev/null \
</dev/null >/dev/null 2>&1 &
I suspect the attempt to get the controlling terminal (it was not connected to any stream even before) has something to do with output paging, though I don't see why git checkout
would need that. Nor why it should fail the operation.