购买github创建私有项目 的私有仓库是个好选择吗

5321人阅读
工具配置(15)
1.本地安装gitosis 、git
gitosis是git的server端,安装很简单
yum &install git.i686 gitosis.noarch
2.配置gitosis
a) 创建key
[root@localhost tmp]# useradd git
[root@localhost tmp]# su git
[git@localhost tmp]$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/git/.ssh/id_rsa):
Created directory '/home/git/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/git/.ssh/id_rsa.
Your public key has been saved in /home/git/.ssh/id_rsa.pub.
The key fingerprint is:
4f:91:ca:56:14:a5:3c:69:cf:86:64:16:e9:f3:01:95 git@localhost.localdomain
The key's randomart image is:
+--[ RSA 2048]----+
+-----------------+
[git@localhost tmp]$
b)初始化gitosis服务端
[git@localhost ~]$ gitosis-init &~/.ssh/id_rsa.pub
[git@localhost ~]$ ll
drwxr-xr-x. 2 git git 4096 Jun
3 21:19 gitosis
drwxr-xr-x. 4 git git 4096 Jun
3 21:17 repositories
[git@localhost ~]$ pwd
[git@localhost ~]$repositories是代码仓库,以工程为单位,一个工程一个文件夹
c)添加用户
[git@localhost ~]$ pwd
[git@localhost ~]$ mkdir github
[git@localhost ~]$ cd git
bash: cd: git: No such file or directory
[git@localhost ~]$ cd github/
[git@localhost github]$ git clone git@192.168.11.128:gitosis-admin.git
Initialized empty Git repository in /home/git/github/gitosis-admin/.git/
remote: Counting objects: 17, done.
remote: Compressing objects: 100% (17/17), done.
remote: Total 17 (delta 4), reused 3 (delta 0)
Receiving objects: 100% (17/17), done.
Resolving deltas: 100% (4/4), done.
[git@localhost github]$ ll
drwxr-xr-x. 4 git git 4096 Jun
3 23:26 gitosis-admin
[git@localhost github]$ cd gitosis-admin/
[git@localhost gitosis-admin]$ ll
-rw-rw-r--. 1 git git
3 23:26 gitosis.conf
drwxrwxr-x. 2 git git 4096 Jun
3 23:26 keydir
[git@localhost gitosis-admin]$ cat gitosis.conf #这个里面添加用户的信息
[group gitosis-admin]
writable = gitosis-admin
members = git@localhost.localdomain hello
[group github]
writable = github
members = git@localhost.localdomain hello
[git@localhost gitosis-admin]$ ll keydir/ #这个里面添加的是ssh-keygen 产生的pubkey
-rw-rw-r--. 1 git git 407 Jun  3 23:26 git@localhost.localdomain.pub
-rw-rw-r--. 1 git git 409 Jun  3 23:26 hello.pub
[git@localhost gitosis-admin]$ 
注意:keydir 存放的名字是hello.pub 那么 gitosis.conf里面使用的名字同样是hello,两者一定要一致
git的管理员,git这个用户去拉去线上的管理文件,同时修改文件然后提交,这样用户hello就添加完毕了
d)添加工程
[git@localhost ~]$ cd repositories/
[git@localhost repositories]$ pwd
/home/git/repositories
[git@localhost repositories]$ ll
drwxrwxr-x. 7 git git 4096 Jun
3 21:17 github.git
drwxr-x---. 8 git git 4096 Jun
3 21:19 gitosis-admin.git
[git@localhost repositories]$ mkdir github.git
[git@localhost repositories]$ git init --bare
[git@localhost repositories]$ cd github.git/
[git@localhost github.git]$ ll -a
drwxrwxr-x.
7 git git 4096 Jun
drwxr-xr-x.
4 git git 4096 Jun
3 21:17 ..
drwxrwxr-x.
2 git git 4096 Jun
3 21:17 branches
-rw-rw-r--.
3 21:17 config
-rw-rw-r--.
3 21:17 description
-rw-rw-r--.
3 21:17 HEAD
drwxrwxr-x.
2 git git 4096 Jun
3 23:14 hooks
drwxrwxr-x.
2 git git 4096 Jun
3 21:17 info
drwxrwxr-x. 11 git git 4096 Jun
3 21:28 objects
drwxrwxr-x.
4 git git 4096 Jun
3 21:17 refs
[git@localhost github.git]$
添加了又一个github名字的工程,工程添加完成但是还得需要去给这个工程添加用户
具体的方式1.git的管理员拉取admin文件,添加一个group---github,同时在group里面添加usermember----hello;2.然后提交给远端,这样hello这个用户就可以使用github这个工程了
至此,自己搭建的私有github就可以使用了。
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:484269次
积分:4892
积分:4892
排名:第4454名
原创:146篇
转载:82篇
评论:41条
(3)(2)(2)(10)(3)(7)(12)(6)(3)(13)(3)(13)(10)(16)(8)(10)(10)(2)(2)(1)(1)(4)(16)(3)(2)(3)(7)(4)(5)(3)(5)(4)(7)(18)(12)

我要回帖

更多关于 github创建私有仓库 的文章

 

随机推荐