零基础Centos6搭建Git服务器,及常见问题解决
1.编译安装git
2.1 服务器端:
#yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-devel
#wget http://git-core.googlecode.com/files/git-1.9.0.tar.gz
#tar zxvf git-1.9.0.tar.gz
#cd git-1.9.0
#make prefix=/usr/local all
#make prefix=/usr/local install #root用户运行
问题:
/bin/sh: cc: command not found
原因:没有安装GCC
方法:yum install gcc
查看版本号:git --version
git version 1.9.0
安装gitosis:gitosis为Git用户权限管理系统,通过管理服务端的/home/git/.ssh/authorized_key文件来执行对用户权限的管理,是一个python模块包
#yum install python python-setuptools
#git clone git://github.com/res0nat0r/gitosis.git
#cd gitosis/
#python setup.py install
显示Finished processing dependencies for gitosis==0.2即表示成功
2.2 客户端安装:
#yum install git
#git --version
git version 1.7.1
4. 服务器上生成git用户,使用git用户并初始化gitosis
添加用户git:
#useradd -r -s /bin/sh -c 'git version control' -d /home/git git
设置权限:
#mkdir -p /home/git
#chown git:git /home/git
在服务器端生成管理库:
Initialized empty Git repository in /home/git//repositories/gitosis-admin.git/ Reinitialized existing Git repository in /home/git/repositories/gitosis-admin.git/
注解:
1. 生成的gitosis-admin为Git的用户访问权限管理库,gitosis通过这个git库来管理所有git库的访问权限。
2. 通过执行初始化,该公钥的拥有者就能修改用于配置gitosis的那个特殊Git仓库了
修改上传权限:
#chmod 755 /home/git/repositories/gitosis-admin.git/hooks/post-update
5. 客户端导出管理
#mkdir -p /git-repo/
#cd /git-repo/
#git clone git@192.168.56.1:gitosis-admin.git
我的代码:git clone ssh://git@107.182.176.97:27390/gitosis-admin.git
#cd gitosis-admin
#find .
./gitosis.conf
./keydir
./keydir/oot@vm1.pub
注解:
gitosis.conf
文件用来设置用户、仓库和权限的控制文件
keydir目录则是保存所有具有访问权限用户公钥的地方
./keydir/root@vm1.pub:如前所述,该用户具有访问权限
6. 客户端创建及设置管理项目
#cd /git-repo/gitosis-admin
查看已经上传密钥
#ls keydir/
root@vm1.pub
授权和权限控制
#vim gitosis.conf
[gitosis]
[group gitosis-admin]
writable = gitosis-admin
members = root@vm1 #显示用户root@vm1.pub是初始化gitosis公钥的拥有者,是唯一能管理gitosis-admin项目的人
[group jay_fans] #组名称
members = root@vm1 #密钥用户名
writable = git-test #项目名称
7. 初始、增加及使用项目git-test
#cd /git-repo
#mkdir git-test
#cd git-test
#git init
#touch README
#git add .
#git commit -a -m "init git-test"
#git remote add origin git@192.168.56.1:git-test.git
#git push origin master
问题:
ERROR:gitosis.serve.main:Repository read access denied
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
原因:服务器端没有添加用户和项目
解决:vim gitosis.conf 添加用户和项目
注解:在新项目git-test里首次推送数据到服务器前,需先设定该服务器地址为远程仓库,但你不用事先到服务器上手工创建该项目的裸仓库— Gitosis 会在第一次遇到推送时自动创建。
Please tell me who you are.
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
原因:没有创建账号
解决:
$ git config --global user.email "lenky0401@163.com"
$ git config --global user.name "lenky.gao"
出处:http://www.tuicool.com/articles/Qjaqqu
问题:git push origin master
Initialized empty Git repository in /home/git/repositories/t18.git/
error: src refspec master does not match any.
error: failed to push some refs to 'ssh://git@107.182.176.97:27390/t18.git'
原因:目录中没有文件,空目录是不能提交上去的
解决:
$ cd myproject
$ git init
$ git add .
$ git commit -m 'initial commit'
$ git remote add origin git@gitserver:/opt/git/project.git
$ git push origin master
出处:http://www.open-open.com/lib/view/open1366080269265.html
8. 客户端增加其他成员公钥到系统中:通过添加用户的公钥到keydir目录即可
#cd /git-repo/gitosis-admin
#cp /path/to/member/public/key keydir/
#git add keydir/member.pub
修改gitosis.conf
[group jay_fans] #组名称
members = jay # 新的密钥用户名
writable = git-test
提交修改:
#git commit -a -m "granted jay commit rights to git-test"
#git push
注解:gitosis实际上是从服务器端的/home/git/.gitosis.conf文件读取信息的,通过以上操作,会将新的权限信息写入到该文件中,如果搞错了配置,导致失去了推送权限,可以通过修改该文件来重新设定,如果你手工编辑该文件的话,它会一直保持到下次向 gitosis-admin
推送新版本的配置内容为止。
成员jay通过以下命令获取代码:
#git clone git@192.168.56.1:git-test.git
相关链接:
http://www.centoscn.com/CentosServer/ftp/2014/0414/2789.html
http://zwm-xl.blog.sohu.com/170050241.html
http://blog.chinaunix.net/uid-26611973-id-3373977.html
零基础Centos6搭建Git服务器,及常见问题解决的更多相关文章
- Git学习笔记(10)——搭建Git服务器
本文主要记录了Git服务器的搭建,以及一些其他的配置,和最后的小总结. Git远程仓库服务器 其实远程仓库和本地仓库没啥不同,远程仓库只是每天24小时开机为大家服务,所以叫做服务器.我们完全可以把自己 ...
- CentOS搭建Git服务器及权限管理
声明:本教程,仅作为配置的记录,细节不展开,需要您有一点linux的命令基础,仅作为配置参考. 1. 系统环境 系统: Linux:CentOS 7.2 64位 由于CentOS已经内置了OpenSS ...
- Ubuntu16 搭建Git 服务器
刚入职一个月左右,昨晚公司给培训了SVN和Git的使用.之前在研究生期间,和导师做项目就一直使用git做版本管理.想起研究生有一段时间,git总出错(秘钥都不好使了,只有某个机器生成的rsa key ...
- (转)初学Git及简单搭建git服务器和客户端
终于搞定,mac自己作为git服务器,mac也是客户端,如何免登 从另外一个linux服务器的上传公钥得到提示 ssh-copy-id -i ~/.ssh/id_rsa.pub git@192.168 ...
- Windows/Linux 环境搭建Git服务器 + vs2012集成git
1. 下载.安装Git 我的系统是Windows 7,需要安装Git for Windows. 下载地址: http://code.google.com/p/msysgit/downloads/lis ...
- 【git】搭建git服务器
在 Linux 下搭建 Git 服务器 目录 ① 安装 Git ② 服务器端创建 git 用户,用来管理 Git 服务,并为 git 用户设置密码 ③ 服务器端创建 Git 仓库 ④ 客户端 clon ...
- 【转】在Linux下搭建Git服务器
在 Linux 下搭建 Git 服务器 环境: 服务器 CentOS6.6 + git(version 1.7.1)客户端 Windows10 + git(version 2.8.4.windows. ...
- 零基础免费搭建个人博客-hexo+github
使用hexo生成静态博客并架设在免费的github page平台 准备 系统: Window 7 64位 使用软件: Git v1.9.5[下载地址] 百度云 360云盘 访问密码 d269 Git官 ...
- 搭建Git服务器及本机克隆提交
前文 Git是什么? Git是目前世界上最先进的分布式版本控制系统. SVN与Git的最主要的区别? SVN是集中式版本控制系统,版本库是集中放在中央服务器的,而干活的时候,用的都是自己的电脑,所以首 ...
随机推荐
- args 、kwargs不定参数通过列表、元组、字典传递
*args .**kwargs是不定参数的表达方法,一般用于函数形参.*args .**kwargs 作为传递参数的函数,在使用过程中,可对*args .**kwargs多个输入,但是效率或者比较麻烦 ...
- git 的搭建与使用
公司之前用的是vpn,然后老大说让我搞一个git.于是,我开始了git的研究之路.... 概念:(说实话,看了还是有些不太理解) git 是一种版本控制系统,是一个命令,是一种工具 g ...
- 干货-Spring3.2.3的所有注解
在用到Spring3的时候,我们需要对耦合的struts2的Action层或者SpringMVC的Controller层加上注解,一般是@Controller和@RequestMapping 看到这里 ...
- 工作ui(2)
做完整个小Demo整理的一些方法和踩过的miniUI的坑,分享出来希望大家批评指正,共同进步. 1.动态创建列:尽量不要直接在html文件里创建列,动态设置在js文件里方面添加.修改等. 首先把列定义 ...
- c++中代理类的学习
https://blog.csdn.net/lcg910978041/article/details/51468680 C++代理类是为了解决这样的问题: 容器通常只能包含一种类型的对象,所以很难在容 ...
- Python查看类或Module的版本号
>>> import keras >>> print keras.__version__ 1.2.0
- python_案例综合:教材记录管理
class Book(): def __init__(self,ISBN,Ftile,Author,Publisher): self.ISBN = ISBN self.Ftile = Ftile se ...
- pacman usage
pacman使用 安装了系统时候, 应该立马使用pacman-mirrors -c China更新源, 再使用pacman -Syyn更新系统 编辑/etc/pacman.conf添加 [archli ...
- jQuery的定时执行和延迟执行
jQuery的定时执行和延迟执行 //延迟执行 setTimeout(function(){ console.log("实战授课,100%就业"); },600); //定时执行 ...
- 浏览器警告:provisional headers are shown
做项目的时候遇到一个问题 后台JAVA,每次发送的都有一次拦截,去转发到登录页面的url 有一个请求是https的,被拦截后显示发生了错误,浏览器警告:provisional headers are ...