---
title: "建立私有的git服务"
author: "taito"
date: "2010-06-03T12:47:01Z"
tags: ["Git", "SSH", "WordPress"]
categories: ["研发管理"]
slug: "git"
draft: false
lastmod: "2010-07-13T15:16:11Z"
id: 682934
url: "https://taito.iteye.com/blog/682934"
---

git官方网站上虽然提供私有的git服务,不过是收费的。一个月最少7$。

 

所以为了节省人民币。自己动手建立自己的git服务端吧。

 

服务器环境：

 

[site5 虚拟主机](http://www.site5.com/in.php?id=78463-39)

[![site5](http://www.site5.com/creative/2008/4/120x60-1.gif)](http://www.site5.com/in.php?id=78463-39)

1、在本地已有项目上，建立git仓库

   cd ~/src/myproject

   git init

   git add *

   `git commit -m "Initial commit"`

 

   添加远程链接的快捷方式

   git remote add origin  ssh://用户名@remote.host.com/~/src/myproject.git

 

   编辑config

```
vi .git/config
```

 

```
[branch "master"]
  remote = origin
  merge = refs/heads/master
```

    加入以上几行

 

    在你运行 git remote 命令时，应该会出现\[remote "origin"]的配置

 

2、在远程服务器上建立git 服务端

   克隆一个空仓库

```
   git clone --bare myproject myproject.git
   touch myproject.git/git-daemon-export-ok
```

 

3、上传项目

 

```
git push origin master
```

 

4、在本地导出项目  
      git clone ssh://用户名@remote.host.com/~/src/myproject.git

3、接着就可以在本地进行一切git 操作了

```
   touch README
   git add *
   git commit -m 'first commit'
   git push origin master
```

4、如果你的虚拟主机不支持git  
   就需要你在服务器上自己安装git，并自己在 ~/.bashrc文件中指定 path

 

===========================

其它的项目托管方

www.unfuddle.com

 

from:  
http://dentharg.wordpress.com/2008/03/03/git-private-repositories-on-shared-hosting/