git 命令
http://www.jb51.cc/article/p-vlyqjlou-bhh.html
安装git
[root@gitserver ~]# yum install git
Is this ok [y/d/N]: y
Complete!
[root@gitserver ~]# git --version
git version 1.8.3.1
创建git管理员账号密码
[root@gitserver ~]# adduser --system --shell /bin/sh --create-home --home-dir /mnt/git git
[root@gitserver git]# passwd git
[root@gitserver ~]# cd /mnt/git
[root@gitserver git]# ls
[root@gitserver git]# mkdir repositories
[root@gitserver git]# chown git:git -R ./repositories
[root@gitserver git]# chmod 700 ./repositories
[root@gitserver git]# su git
sh-4.2$ cd /mnt/git/repositories/
sh-4.2$ mkdir test.git
sh-4.2$ cd test.git/
sh-4.2$ git --bare init
Initialized empty Git repository in /mnt/git/repositories/test.git/
安装gitolite
sh-4.2$ git clone https://github.com/sitaramc/gitolite
Cloning into 'gitolite'...
remote: Counting objects: 9355,done.
remote: Total 9355 (delta 0),reused 0 (delta 0),pack-reused 9355
Receiving objects: 100% (9355/9355),2.94 MiB | 963.00 KiB/s,done.
Resolving deltas: 100% (5789/5789),done.
sh-4.2$ mkdir $HOME/bin
sh-4.2$ ls
authorized_keys bin gitolite repositories
创建管理员账号SSH免登陆
sh-4.2$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/mnt/git/.ssh/id_rsa): y
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in y.
Your public key has been saved in y.pub.
The key fingerprint is:
ed:da:0b:23:e5:a1:92:2a:d7:87:c8:ae:e3:67:71:ac git@gitserver
The key's randomart image is:
+--[ RSA 2048]----+
| |
| |
| |
| . |
| . S . |
| . + + o |
| . o*.o + . |
|o +Eo... = |
|oB= . . o. |
+-----------------+
sh-4.2$ ls .ssh/
-sh-4.2$ cp .ssh/id_rsa.pub git.pub
-sh-4.2$ touch .ssh/authorized_keys && chmod 600 .ssh/authorized_keys
-sh-4.2$ $HOME/bin/gitolite setup -pk git.pub
warning: You ran 'git add' with neither '-A (--all)' or '--ignore-removal',
whose behavIoUr will change in Git 2.0 with respect to paths you removed.
Paths like 'keydir/git.pub' that are
removed from your working tree are ignored with this version of Git.
* 'git add --ignore-removal <pathspec>',which is the current default,
ignores paths you removed from your working tree.
* 'git add --all <pathspec>' will let you also record the removals.
Run 'git status' to check the paths you removed from your working tree.
然后去/mnt/git/repositories 里面,可以看见仓库文件.gitolite-admin.git 和test.git 一个是管理仓库的,一个是测试用
还是在git用户下
ssh git@127.0.0.1
PTY allocation request Failed on channel 0
hello git,this is git@gitserver running gitolite3 v3.6.6-9-gd6e8a0f on git 1.8.3.1
R W gitolite-admin
R W testing
Connection to 127.0.0.1 closed.
出现如下内容:
hello git,this is git@linux-dev running gitolite3 v3.5.2-4-g62fb317 on git1.8.1.2
R W gitolite-admin
R W testing
代表gitolite工作正常
如果出现 WARNING: keydir/git_key.pub duplicates a non-gitolite key,sshd will ignore it
这种警告,说明配置有些问题,需要删除/ment/git目录下的
.gitolite 和.gitolite.rc 和 repositories 和 ~/.ssh/authorized_keys四个文件!!
可以使用该命令删除 rm -fr .*
然后重新执行管理员SSH免登陆操作
创建gitolite-admin目录
-sh-4.2$ git clone git@127.0.0.1:gitolite-admin
Cloning into 'gitolite-admin'...
The authenticity of host '127.0.0.1 (127.0.0.1)' can't be established. ECDSA key fingerprint is 65:05:67:e9:43:5b:39:b7:bc:d9:9e:33:a8:74:7c:2e. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '127.0.0.1' (ECDSA) to the list of known hosts. remote: Counting objects: 6,done. remote: Compressing objects: 100% (4/4),done. remote: Total 6 (delta 0),reused 0 (delta 0) Receiving objects: 100% (6/6),done. -sh-4.2$ ls authorized_keys gitolite projects.list bin gitolite-admin repositories
sh-4.2$ cd gitolite-admin/keydir/
sh-4.2$ ls
git.pub
sh-4.2$ vim username.pub #根据用户名改成用户名.pub方便权限管理直观查看
在客户端生成的pub内容贴进去
添加仓库权限
sh-4.2$ vim conf/gitolite.conf
repo gitolite-admin
RW+ = git
repo test
RW+ = git test
repo testing
RW+ = @all
配置全局用户标识,客户端使用时也是如此
sh-4.2$ git config --global user.email "git@example.com"
sh-4.2$ git config --global user.name "git"
重新提交当前管理仓库配置信息到本地库中
git add keydir
git commit -m 'add some user' git push sh-4.2$ git commit -m "test" [master e3870a9] test 2 files changed,6 insertions(+) create mode 100644 keydir/xialeme.pub
管理员root重启shd服务
客户端测试
windows使用git时出现:warning: LF will be replaced by CRLF
$ git config --global core.autocrlf false //禁用自动转换
客户端测试
sh-4.2
$ git clone git@192.168.1.250:/mnt/git/repositories/test.git
Cloning into ‘test’…
remote: Counting objects: 3,done.
remote: Total 3 (delta 0),reused 0 (delta 0)
Receiving objects: 100% (3/3),done.
Checking connectivity… done.
添加新用户
管理员从用户那获取用户的公钥,并将公钥按照username.pub(只要能区分人员就好,邮箱.pub也可以)格式重命名。
执行git push 命令 将 本地库 推送到远程库(即gitolite服务器上的gitolite-admin中)
6.授权 管理员进入本地哭gitolite-admin中,编辑conf/gitolite.conf
git
http://blog.csdn.net/zzfenglin/article/details/53147604
download
http://download.csdn.net/download/chengjierui/9405951