49

Git 服务器搭建

 7 years ago
source link: https://zdb.im/git-server.html?amp%3Butm_medium=referral
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

安装Git

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

创建用户组和用户

$ groupadd git
$ useradd git -g git

创建证书登录

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

生成密钥

ssh-keygen -t rsa -C "我的SSH密钥"

生成密钥 并将 公钥导入到/home/git/.ssh/authorized_keys (一行一个公钥), 用户保留私钥id_rsa ;

私钥文件名为 id_rsa , 直接放入 C:Userszdb.sshid_rsa 或 /home/zdb/.ssh/id_rsa ;

原则上一个员工一对证书, 离职后吊销证书(从authorized_keys内删除对应的一行公钥);

初始化Git仓库

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

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

$ chown -R git:git slim3.git

克隆或加入已有项目remote

6.1 克隆


$ git clone [email protected]:/home/gitrepo/slim3.git
Cloning into 'slim3'...
warning: You appear to have cloned an empty repository.
Checking connectivity... done.

6.2 加入remote 地址

git remote add -f [email protected]:/home/gitrepo/slim3.git

后续新项目

执行 步骤5 即可

后续有新员工

执行 步骤4 即可

Windows环境客户端下载

百度: git scm


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK