开发者

What kind of server do you use to host a Git repository?

开发者 https://www.devze.com 2023-03-30 23:25 出处:网络
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.

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开发者_JS百科 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.


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.


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:

  • git daemon (no authentication there)
  • Apache server (with the smart http cgi 'git-http-backend' activated)
  • ssh daemon

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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消