在centos6上搭建git服务器

来源:互联网 发布:sas编程 编辑:程序博客网 时间:2024/05/01 12:35

前置条件

文中所使用的环境:centos6.5(64bit)
1. 下载安装git server(以root用户执行)

su
yum update
yum install git-core

检查Git是否安装成功

git –version

git version 1.7.1

2. 创建用户组及用户(以root用户执行)
创建developers用户组,然后添加git用户,该用户属于developers用户组,用户根目录为/home/git

groupadd developers
useradd -g developers git -d /home/git
passwd git

然后通过编辑/etc/group文件将git加入到developers后面

developers:x:504:git


使用教程

1. 在Server端(以git用户执行)

  • 创建项目根目录

su git
cd /home/git
mkdir -p projName.git

  • 用命令查看创建的目录

ls -l

最后看到的信息是:

drwxr-xr-x. 2 git developers 4096 614 13:34 projName.git

(如果用户组或者用户信息不对,请执行下面命令)

chgrp developers projName.git
chown git projName.git
chmod g+rws projName.git

  • 初始化项目

git init –bare –shared projName.git

Initialized empty shared Git repository in /home/git/projName.git/

2. 在客户端(以Eclipse lun版本EGit做客户端)

  • 新建测试项目

  • 分享项目

在Eclipse右键项目名 Team->Share Project
分享项目

  • 提交

右键项目名 Team->Commit
提交

git服务器地址

提交到服务器,Finish
提交到服务器

(如果遇到eclipse Transport Error: The authenticity of host can't be established),解决方案请参考:Eclipse + EGit - “The authenticity of host … can’t be established” challenge


0 0
原创粉丝点击