GIT服務器項目部署和自動同步


1.1、初始化Git倉庫
首先我們選定一個目錄作為Git倉庫,假定是/home/data/share/share.git,在/home/data/目錄下輸入命令:

$ cd /home/data/
$ mkdir share
$ chown git:git share/
$ cd share

$ git init --bare share.git
Initialized empty Git repository in /home/data/share/share.git/

 

以上命令Git創建一個空倉庫,服務器上的Git倉庫通常都以.git結尾。然后,把倉庫所屬用戶改為git:

$ chown -R git:git  share.git

 

1.2 配置自動同步

$ cd /home/data/share/share.git/hooks

vim post-receive

#!/bin/bash
git --work-tree=/web/share checkout -f

chmod -R 777 post-receive

 

1.3檢出代碼,到nginx指定的項目目錄

cd /web
git clone /home/data/share/share.git/
chmod -R 777 share

 

 Windows客戶端: 

git clone git@39.107.77.206:/home/data/share/share.git

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM