git 命令
http://www.jb51.cc/article/p-vlyqjlou-bhh.html
安装git
[root@gitserver@H_404_8@ ~]# yum install git
Is this@H_404_8@ ok [y/d/N]: y
Complete!
[root@gitserver@H_404_8@ ~]# git --version@H_404_8@
git version@H_404_8@ 1.8@H_404_8@.3.1
创建git管理员账号密码
[root@gitserver@H_404_8@ ~]# adduser --system --shell /bin/sh --create-home --home-dir /mnt/git git@H_404_8@
[root@gitserver@H_404_8@ git]# passwd git@H_404_8@
[root@gitserver@H_404_8@ ~]# cd /mnt/git@H_404_8@
[root@gitserver@H_404_8@ git]# ls@H_404_8@
[root@gitserver@H_404_8@ git]# mkdir repositories@H_404_8@
[root@gitserver@H_404_8@ git]# chown git:git -R ./repositories@H_404_8@
[root@gitserver@H_404_8@ git]# chmod 700 ./repositories@H_404_8@
[root@gitserver@H_404_8@ git]# su git@H_404_8@
sh-4.2@H_404_8@$ @H_404_8@cd /mnt/git/repositories/
sh-4.2@H_404_8@$ @H_404_8@mkdir test.git
sh-4.2@H_404_8@$ @H_404_8@cd test.git/
sh-4.2@H_404_8@$ @H_404_8@git --bare init
Initialized@H_404_8@ empty Git@H_404_8@ repository in@H_404_8@ /mnt/git/repositories/test.git/
安装gitolite
sh-4.2@H_404_8@$ git clone https://github.com/sitaramc/gitolite
Cloning into 'gitolite'@H_404_8@...@H_404_8@
remote: Counting objects: 9355@H_404_8@,done.
remote: Total 9355@H_404_8@ (delta 0@H_404_8@),reused 0@H_404_8@ (delta 0@H_404_8@),pack-reused 9355@H_404_8@
Receiving objects: 100@H_404_8@% (9355@H_404_8@/9355@H_404_8@),2.94@H_404_8@ MiB | 963.00@H_404_8@ KiB/s,done.
Resolving deltas: 100@H_404_8@% (5789@H_404_8@/5789@H_404_8@),done.
sh-4.2@H_404_8@$ mkdir $HOME/bin
sh-4.2@H_404_8@$ ls
authorized_keys bin gitolite repositories
创建管理员账号SSH免登陆
sh-4.2@H_404_8@$ ssh-keygen -t rsa
Generating public@H_404_8@/private@H_404_8@ rsa key@H_404_8@ pair.
Enter file in@H_404_8@ which to@H_404_8@ save the key@H_404_8@ (/mnt/git/.ssh/id_rsa): y
Enter passphrase (empty for@H_404_8@ no passphrase):
Enter same passphrase again:
Your identification has been saved in@H_404_8@ y.
Your public@H_404_8@ key@H_404_8@ has been saved in@H_404_8@ y.pub.
The key@H_404_8@ fingerprint is@H_404_8@:
ed:da:0@H_404_8@b:23@H_404_8@:e5:a1:92@H_404_8@:2@H_404_8@a:d7:87@H_404_8@:c8:ae:e3:67@H_404_8@:71@H_404_8@:ac git@gitserver
The key@H_404_8@'s randomart image is:@H_404_8@
+--[ RSA 2048@H_404_8@]----+
| |
| |
| |
| . |
| . S . |
| . + + o |
| . o*.o + . |
|o +Eo... = |
|oB= . . o. |
+-----------------+
sh-4.2@H_404_8@$ ls .ssh/
-sh-4.2@H_404_8@$ cp .ssh/id_rsa.pub git.pub
-sh-4.2@H_404_8@$ touch .ssh/authorized_keys && chmod 600@H_404_8@ .ssh/authorized_keys
-sh-4.2@H_404_8@$ $HOME/bin/gitolite setup -pk git.pub
warning: You ran 'git add' with neither '-A (--all)' or '--ignore-removal',@H_404_8@
whose behavIoUr will change in@H_404_8@ Git 2.0@H_404_8@ with@H_404_8@ respect to@H_404_8@ paths you removed.
Paths like@H_404_8@ 'keydir/git.pub' that are@H_404_8@
removed from@H_404_8@ your working tree are ignored with@H_404_8@ this version of@H_404_8@ Git.
* 'git add --ignore-removal <pathspec>@H_404_8@',which is the current default,@H_404_8@
ignores paths you removed from@H_404_8@ your working tree.
* 'git add --all <pathspec>@H_404_8@' will let you also record the removals.@H_404_8@
Run 'git status' to check the paths you removed from your working tree.@H_404_8@
然后去/mnt/git/repositories 里面,可以看见仓库文件.gitolite-admin.git 和test.git 一个是管理仓库的,一个是测试用
还是在git用户下
ssh git@127.0@H_404_8@.0@H_404_8@.1@H_404_8@
PTY allocation request Failed on@H_404_8@@H_404_8@ channel 0@H_404_8@
hello git,this is@H_404_8@ git@gitserver running@H_404_8@ gitolite3 v3.6@H_404_8@.6@H_404_8@-9@H_404_8@-gd6e8a0f on@H_404_8@@H_404_8@ git 1.8@H_404_8@.3@H_404_8@.1@H_404_8@
R W gitolite-admin
R W testing
Connection to@H_404_8@ 127.0@H_404_8@.0@H_404_8@.1@H_404_8@ closed.
出现如下内容:
hello git,this@H_404_8@ is@H_404_8@ git@linux@H_404_8@-dev running gitolite3 v3.5@H_404_8@.2@H_404_8@-4@H_404_8@-g62fb317 on@H_404_8@ git1.8@H_404_8@.1@H_404_8@.2@H_404_8@
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@H_404_8@$ git clone git@127.0@H_404_8@.0@H_404_8@.1@H_404_8@:gitolite-admin
Cloning into 'gitolite-admin'@H_404_8@...@H_404_8@
The authenticity of host '127.0.0.1 (127.0.0.1)'@H_404_8@ 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 '@H_404_8@127.0@H_404_8@.0@H_404_8@.1@H_404_8@' (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@H_404_8@
sh-4.2@H_404_8@$ @H_404_8@cd gitolite-admin/keydir/
sh-4.2@H_404_8@$ @H_404_8@ls
git.pub
sh-4.2@H_404_8@$ @H_404_8@vim username.pub #根据用户名改成用户名.pub方便权限管理直观查看@H_404_8@
在客户端生成的pub内容贴进去
添加仓库权限
sh-4.2@H_404_8@$ @H_404_8@vim conf/gitolite.conf
repo gitolite-admin
RW@H_404_8@+ = git
repo test
RW@H_404_8@+ = git test
repo testing
RW@H_404_8@+ = @all@H_404_8@
配置全局用户标识,客户端使用时也是如此
sh-4.2@H_404_8@$ @H_404_8@ git config --global user.email "git@example.com"@H_404_8@
sh-4.2@H_404_8@$ @H_404_8@ git config --global user.name "git"@H_404_8@
重新提交当前管理仓库配置信息到本地库中
git add keydir
git commit@H_404_8@ -m 'add some user'@H_404_8@ git push sh-4.2@H_404_8@$ git commit@H_404_8@ -m "test"@H_404_8@ [master e3870a9] test 2@H_404_8@ files changed,6@H_404_8@ insertions(+) create@H_404_8@ mode 100644@H_404_8@ keydir/xialeme.pub@H_404_8@
管理员root重启shd服务
客户端测试
windows使用git时出现:warning: LF will be replaced by CRLF
$ git config --global@H_404_8@ core.autocrlf false@H_404_8@ //禁用自动转换 @H_404_8@
客户端测试
sh-4.2@H_404_8@
$ 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