找一臺服務器,首先要安裝gitgit
yum install git
添加git用戶,而且設置shell爲/usr/bin/git-shell,目的是爲了避免讓git用戶遠程登錄github
useradd -s /usr/bin/git-shell git
cd /home/git //沒有就建立 建立authorized_keys文件,並更改屬主、屬組和權限,用來存客戶端機器上的公鑰shell
mkdir .ssh touch .ssh/authorized_keys chown -R git.git .ssh chmod 600 .ssh/authorized_keys
定好存儲git倉庫的目錄,好比 /data/gitrootvim
mkdir /data/gitroot cd /data/gitroot git init --bare sample.git # 會建立一個裸倉庫,裸倉庫沒有工做區,由於服務器上的Git倉庫純粹是爲了共享,因此不讓用戶直接登陸到服務器上去改工做區,而且服務器上的Git倉庫一般都以.git結尾 chown -R git.git sample.git
以上操做是在git服務器上作的,平時git服務器是不須要開發人員登陸修改代碼的,它僅僅是充當着一個服務器的角色,就像github同樣,平時操做都是在咱們本身的pc上作的 首先要把客戶端上的公鑰放到git服務器上/home/git/.ssh/authorized_keys文件裏 在客戶端上(本身pc)克隆遠程倉庫centos
git clone git@ip:/data/gitroot/sample.git
此時就能夠在當前目錄下生成一個sample的目錄,這個就是咱們克隆的遠程倉庫了。進入到這裏面,能夠開發一些代碼,而後push到遠程。瀏覽器
gitlab官網 https://about.gitlab.com/gitlab-com/ bash
官方安裝文檔 https://about.gitlab.com/installation/?version=ce//centos-7 (ce/ee) 要求服務器內存很多於2g服務器
vim /etc/yum.repos.d/gitlab.repo #加入以下內容ssh
[gitlab-ce] name=Gitlab CE Repository baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/ gpgcheck=0 enabled=1
安裝 && 執行ide
yum install -y gitlab-ce gitlab-ctl reconfigure
使用gitlab
netstat -lnpt #查看監聽端口 gitlab-ctl stop/restart/start/status 瀏覽器訪問gitlab,輸入ip便可 默認管理員root,無密碼,它會讓咱們去定義一個密碼 gitlab經常使用命令 https://www.cnyunwei.cc/archives/1204 gitlab備份 gitlab-rake gitlab:backup:create 備份目錄在/var/opt/gitlab/backups gitlab 恢復 先停服務 gitlab-ctl stop unicorn ; gitlab-ctl stop sidekiq gitlab-rake gitlab:backup:restore BACKUP=xxxxx (這裏是一個編號,即備份文件的前綴) 再啓動服務 gitlab-ctl start