Wednesday, December 23, 2009

Cloning a git repo over ssh on Snow Leopard

I had trouble cloning a git repo between my home iMac and work MacBook Pro, both running Snow Leopard.

It should be as easy as (porkchop-sandwiches is my work machine name. That's right.):

git clone ssh://tony@porkchop-sandwiches.local/~/work/repo

But that was failing with:

bash: git-upload-pack: command not found
fatal: The remote end hung up unexpectedly

It sounded like the problem was that when logging into ssh I wasn't getting my work machine's user's path, which had all the git stuff in it. This is what I googled: http://stackoverflow.com/questions/225291/git-upload-pack-command-not-found-how-to-fix-this-correctly, and sure enough this command showed that my PATH wasn't what I expected:

ssh tony@porkchop-sandwiches.local echo \$PATH

I tried the solution at stackoverflow, by symlinking .profile to .bashrc but it didn't work even though the PATH was now correct. I don't know what was going on, but one of the other possible solutions on the stackoverflow lead me to this: http://kerneltrap.org/mailarchive/git/2008/6/18/2159464, which I then did, and it then did work. It basically forces SSH logins to execute that custom script as the command, which figures out whether to load .profile or not based on if there was a command passed, and then executes the original command if there was one.

I'm off to the races now!

Posted via email from Tony Hillerson's Posterous

No comments: