2

This is probably the most elementary git question imaginable.

Let's say I start a project and create a Git repository for it on my VPS host.

In SVN you can run an SVN server, serve SVN over Apache, connect to the repo over ssh.

What is the Git analogy to that? Do I need to run a Git daemon? Is there a git:// protocol?

Or is it that on my dev machine I run $ git xyz commands and they communicate under the hood via ssh?

(BTW, I need to host my own repository. GitHub is great, it isn't a good fit for my projects.)

In case it matters, VPS machine in CentOS Linux and dev machine is OS X.

Tekkub
  • 27,151
  • 2
  • 27
  • 20
Ethan
  • 52,651
  • 60
  • 180
  • 231

3 Answers3

3

The easiest way to host a git repo is over ssh.

On your server, create an empty repository with:

cd my_project_folder
git init --shared --bare

on your dev machine, clone the empty repository and start using it.

git clone username@myserver:my_project_folder

Where username is your ssh username and myserver is your server host.

Now you have a copy of the repository, add your files and make a first commit e.g.

cd my_project_folder
touch README
git add README
git commit -m'Initial Commit'
git push origin master # push to your server

If you look in the .git/config file, you'll see that a "remote" host is automatically set up for you pointing to your server.

Charles Ma
  • 41,485
  • 21
  • 80
  • 98
2

If you have a shared path access to your remote machine, it can be enough!
A simple USB key can be enough, with a remote repo as one file (a "bundle").

But if you have a true remote server, then you need a process listening for your git operations:

See the Git protocols in the Pro Git Book.

The Gitolite project is only there for authorization (not authentication).
In itself, it doesn't listen to any request (it plugs itself on top of ssh, or can be called from an Apache configuration).
Gitolite will allow you to avoid needing a full interactive ssh session, filtering all your commands and allowing only the git-related ones, for the repos where you have the necessary permissions.

Community
  • 1
  • 1
VonC
  • 1,042,979
  • 435
  • 3,649
  • 4,283
1

At work we use Gitolite as a private git hosting service.

What it does is to create a simple server, that can be accessed via ssh internally. Basically, to access a remote repository, you would do this:

git clone gitolite@servername:project_name

I can recommend this free online book on git: www.progit.org, and specifically the gitolite section: http://progit.org/book/ch4-8.html

Daniel
  • 300
  • 2
  • 7
  • +1 - The use case and infrastructure described in the question is perfect for gitolite. NB: The gitolite-like project gitosis seems to still attract new users, despite being abandoned and outdated. Gitolite is the thing, not gitosis. – Dan Ray Aug 24 '11 at 14:19
  • Thanks. Gitolite sounds awesome. But I think it may be overkill for my situation. It looks like it's intended for when you have a complex project and you want to provide differential access to various parts of it to various people and groups. I'm mostly dealing with one and two person projects and don't need fine-grained access control. I'm thinking just using ssh may be adequate. – Ethan Aug 24 '11 at 19:57