Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> Linux 伺服器

Linux 下 Mercurial(hg)伺服器配置說明

Mercurial(hg)在國內使用人數不多,中文資料相對匱乏,官方網站 https://www.selenic.com/mercurial/ 有些許資源。整體而言,hg 還是相當好用的。以下說明 hg 伺服端的配置,基本用法請參考官網,操作前請先下載安裝 hg。

一、建立使用者 hgrepo

其他使用者將用這個帳戶向 hg 伺服器 push 程式碼:

useradd hgrepo -d /home/hgrepo
passwd hgrepo

二、建立程式碼倉庫

若倉庫名為 project.hg:

cd /home/hgrepo
mkdir project.hg
cd project.hg
hg init

建立測試檔並提交:

echo "hello, mercurial" > sample.txt
hg add
hg ci

三、開啟 http 服務

先確認權限正確:

chown hgrepo.hgrepo /home/hgrepo/project.hg -R
chmod og+rw /home/hgrepo/project.hg -R

再開啟連接埠:

cd /home/hgrepo/project.hg
hg serve -p 8002 &

把這些寫入 /etc/rc.local 即可開機自動運行。

四、使用 hg

clone 到本地(假設伺服器名為 test):hg clone https://test:8002,本地便會出現 project.hg 的副本。

修改用戶端 .hg/hgrc,加上:

[paths]
default = https://test:8002
default-push = ssh://hgrepo@test//home/hgrepo/project.hg/
[ui]
username=shaohui.zheng

如此即可用 hg push 提交程式碼,系統會詢問 hgrepo 使用者的密碼。祝順利。

Copyright © Linux教程網 All Rights Reserved