Linux的centos搭建git伺服器

來源:互聯網
上載者:User

標籤:

1.安裝git用yum install git-core(伺服器)

2.建立裸倉庫(伺服器)

[[email protected]]$ mkdir /home/workspace[[email protected]]$ cd /home/workspace[[email protected]]$ git init -bare wwwroot.git

 

3.給許可權(伺服器)

chown -R git:git wwwroot.git

4.添加git使用者和密碼(伺服器)

adduser git

passwd git 123

5.禁止shell登陸如果不知道git在哪裡用:which git-shell 尋找出來填寫正確路徑(伺服器)

編輯/etc/passwd

git:x:1001:1001:,,,:/home/git:/bin/bash

改為:

git:x:1001:1001:,,,:/home/git:/usr/bin/git-shell

6.用clone遠程下載git項目(用戶端)

git clone [email protected]115.28.38.789:/home/workspacewwwroot.git

IP和路徑一定要填寫正確

7.用戶端可以操作git相關操作了

git add *

git commit -m ‘add‘

git remote add origin [email protected]:/home/workspacewwwroot.git   (只在第一次關聯的時候使用,第二次不需要在使用,直接push就可以了)

git push origin master

項目每次修改或添加就可以這些命令完成

8.進行git和web目錄關聯,同步瀏覽網站

設定鉤子,這樣每次運行git就可以同步提交瀏覽網站了

[[email protected]]$ cd /home/workspace/wwwroot.git/hooks[[email protected]]$ cat > post-receive <<EOF>#!/bin/bash>git --work-tree=/home/website/wwwroot checkout -f >EOF[[email protected]]$ chmod +x post-receive

分布式伺服器,每一個電腦都可以作為git伺服器,每個電腦都是一個節點!祝君好運!

Linux的centos搭建git伺服器

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.