歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux服務器 >> Linux下Mercurial (hg)配置說明

Linux下Mercurial (hg)配置說明

日期:2017/3/2 16:54:14   编辑:Linux服務器

這個工具在國內很少人使用,所以中文資料匮乏.只有官方的website上有一些少得可憐的中文資料了.不過總體上來說,hg還是比較好用的。

這裡紹一下hg服務器的配置。關於hg在基本用法參見mercrial的官方網站。在做以下操作時,請到 http://www.selenic.com/mercurial/下載安裝hg.

1.建立用戶hgrepo

其它用戶將用這個賬戶用hg服務器push代碼。

useradd hgrepo -d /home/hgrepo # add user hgrepo
passwd hgrepo

2.建立hg代碼倉庫

如果代碼倉庫名稱為project.hg,則可用如下命令。

cd /home/hgrepo
mkdir project.hg
cd project.hg
hg init # 初始化代碼倉庫
建立一個測試文件

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

3. 打開http

打開一個端口,讓遠程用戶可以clone倉庫中的代碼.
在打開端口前請確定文件權限正確。

更改文件權限
chown hgrepo.hgrepo /home/hgrepo/project.hg -R
chmod og+rw /home/hgrepo/project.hg -R
打開端口

cd /home/hgrepo/project.hg -R
hg serve -p 8002 &
可將上面兩行加入/etc/rc.local這樣就可以在開機的時候自動運行了。

4.使用hg

完成步驟3以後,我們就可以使用了。

clone到本地

例如你的服務器的名字為test.

hg clone http://test:8002
然後在本地目錄就會出現一個project.hg的一個copy.

修改Client端的配置

更改.hg/hgrc,加上default-push和username

[paths]
default = http://test:8002
default-push = ssh://hgrepo@test//home/hgrepo/project.hg/
[ui]
username=shaohui.zheng
這樣你就可用hg push 向服務器提交code了。這時服務器會問你passward,這個password就是用戶hgrepo的password.

Good Luck.

官方網站

http://www.selenic.com/mercurial/

Copyright © Linux教程網 All Rights Reserved