Dienstag, 14. Februar 2012

How to access a remote git repository in your local network?

I don't always want to push my changes to my online repository, just to pull them
an instant later when I switch the machine I'm working with.

So how to access a git repository on a machine in the same network?
(I'm working on Mac OS but this should be applicable for Linux as well.)

First make sure ssh is enabled and the user you log in with, has access to the directory
where the remote repository is located.

Then run



git pull git+ssh://fred@fred-air.local/~/my/repo master

Maybe you'll get following exception:

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

This stackoverflow thread pointed me into the right direction.

In my case I had to edit the .bashrc on the remote machine located
in the home directory of the user I logged in with.

I added git-upload-pack located in /usr/local/git/bin to the PATH and it worked like
a charm.