通知短信+运营短信,5秒速达,支持群发助手一键发送🚀高效触达和通知客户 广告
[TOC] > [runoob](https://www.runoob.com/git/git-server.html) ### 1、安装Git ``` $ yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-devel $ yum install git $ groupadd git $ useradd git -g git ``` ### 2、创建证书登录 创建证书的命令 ``` ssh-keygen cat id_rsa.pub >> /home/git/.ssh/authorized_keys ``` 收集所有需要登录的用户的公钥, 公钥位于`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/runoob.git`,在`/home/gitrepo`目录下输入命令: ``` $ cd /home $ mkdir gitrepo $ chown git:git gitrepo/ $ cd gitrepo $ git init --bare runoob.git Initialized empty Git repository in /home/gitrepo/runoob.git/ ``` 以上命令Git创建一个空仓库,服务器上的Git仓库通常都以.git结尾。然后,把仓库所属用户改为git: ``` $ chown -R git:git runoob.git ``` ### 4、克隆仓库 ``` $ git clone git@192.168.45.4:/home/gitrepo/runoob.git $ touch a.txt $ git add a.txt $ git commit -m "init" $ git push origin master //第一次提交push,需要执行的命令 $ git push ```