1

I'd like to share some Ruby on Rails code between the PCs and the Mac.

Currently, what is the best way to set up a local Git machine so that all the Mac and PC can connect to it to do pull and push?

Is it best to set up on a Mac and then let other Mac or PC connect to it?

Or is it equally ok using a PC to set it up (but ssh daemon seem to have slow issue as on How to setup PC and Mac for using git and may not work as well?)

What about the solution of using git daemon instead?

Community
  • 1
  • 1
nonopolarity
  • 146,324
  • 131
  • 460
  • 740

1 Answers1

3

git daemon is not a good solution for push, as it doesn't support any authentication.

The simplest method is to enable "Remote Login" on the OS X machine (SSH server). If you have git installed, you need no further configuration (except for user accounts) to make git work.

Yann Ramin
  • 32,895
  • 3
  • 59
  • 82
  • don't I have to do ssh keygen on the PC...? and add those pub keys to the Mac? – nonopolarity Apr 02 '11 at 01:07
  • If you don't want to use passwords, yes, otherwise password authentication will work without keys. – Yann Ramin Apr 02 '11 at 01:07
  • so I guess the ssh solution is like logging in and running that local git on the Mac and let it comminicate with the git on the PC? (instead of talking to a git server) – nonopolarity Apr 02 '11 at 01:15
  • @動靜能量: Yes. Its still a "git server" in the same way that `git daemon` is a git server (smart network protocol), but SSH is used as the transport, security, and invocation mechanism. This is standard practice for git. – Yann Ramin Apr 02 '11 at 01:17
  • @動靜能量: Pretty much. There are some more details under the hood, but essentially, when you push or pull via ssh, git internally uses ssh to log in to the remote machine, invokes certain git commands there (primarily `git upload-pack` and `git receive-pack`), and runs corresponding commands on your end. It makes the two machines talk to each other by controlling both sides. – Cascabel Apr 02 '11 at 01:19
  • if I try `git push ssh://username@192.168.1.31/ master` it asks for password and print out a whole series of `/Users/username/.bashrc: line 18: a: command not found` but on the remote machine I clearly have `alias a='alias'` in front of it... and then it prints out `bash: git-receive-pack: command not found` and `fatal: The remote end hung up unexpectedly` – nonopolarity Apr 02 '11 at 02:27
  • @動靜能量: You've got several problems. First, your bashrc needs some cleanup. Aliases are not expanded in non-interactive shells. My guess is that the command involving `a` (whatever it is) doesn't actually need to be run here, and you can protect yourself with a `[ -z "$PS1" ] && return` above any interactive shell setup. Second, it won't work even once your bashrc is sorted out. You need to specify the path to the repository on the remote, e.g. `me@hostname:~/git/project.git`. And finally, you might not have `git` in your path, but it's hard to say with your bashrc not working. – Cascabel Apr 02 '11 at 02:48
  • so I just need to spell out all my alias for the purpose of SSH? (cannot `alias a='alias'` and use `a`, but need to spell it out) – nonopolarity Apr 03 '11 at 17:24