关于git:第十二篇-Git-服务器搭建之Spring-Cloud直播商城-b2b2c电子商务技术总结

4次阅读

共计 965 个字符,预计需要花费 3 分钟才能阅读完成。


Git 服务器搭建
上一章节中咱们近程仓库应用了 Github,Github 公开的我的项目是收费的,2019 年开始 Github 公有存储库也能够无限度应用。

这当然咱们也能够本人搭建一台 Git 服务器作为公有仓库应用。

接下来咱们将以 Centos 为例搭建 Git 服务器。

1、装置 Git

$ yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-devel
$ yum install git

接下来咱们 创立一个 git 用户组和用户,用来运行 git 服务:

​​

$ groupadd git
$ useradd git -g git

2、创立证书登录
收集所有须要登录的用户的公钥,公钥位于 id_rsa.pub 文件中,把咱们的公钥导入到 /home/git/.ssh/authorized_keys 文件里,一行一个。

如果没有该文件创建它:

$ cd /home/git/
$ mkdir .ssh
$ chmod 755 .ssh
$ touch .ssh/authorized_keys
$ chmod 644 .ssh/authorized_keys

3、初始化 Git 仓库
首先咱们选定一个目录作为 Git 仓库,假设是 /home/gitrepo/xxx.git,在 /home/gitrepo 目录下输出命令:

​​


$ cd /home
$ mkdir gitrepo
$ chown git:git gitrepo/
$ cd gitrepo

$ git init --bare xxx.git
Initialized empty Git repository in /home/gitrepo/xxx.git/

以上命令 Git 创立一个空仓库,服务器上的 Git 仓库通常都以.git 结尾。而后,把仓库所属用户改为 git:

`$ chown -R git:git xxx.git
`
4、克隆仓库

$ git clone git@192.168.45.4:/home/gitrepo/xxx.git
Cloning into 'xxx'...
warning: You appear to have cloned an empty repository.
Checking connectivity... done.
1

92.168.45.4 为 Git 所在服务器 ip,你须要将其批改为你本人的 Git 服务 ip。
这样咱们的 Git 服务器装置就实现。

正文完
 0