银河

SKYIV STUDIO

  博客园 :: 首页 ::  ::  :: 订阅 订阅 :: 管理 ::
  221 随笔 :: 2 文章 :: 2262 评论 :: 48 引用

概述

Tower Joo 在“你使用源码管理工具吗?”中推荐 Mercurial 分布式源码管理工具和提供 code hosting 服务的 bitbucket.org 网站。该网站的用户分为 Free、Amateur、Pro、Large 和 Team 五个级别。其中免费的 Free 级别提供 1 个 private 和任意多个 public 的代码库(repository),可用磁盘空间为 150 MB。

另外,Google Code 网站也提供免费的 code hosting 服务,她支持 SubversionMercurial 两种源码管理工具。但是,我总觉得 Google Code 用起来不如 bitbucket.org 顺手。 :)

安装 Mercurial

Ubuntu 操作系统: 使用 $ sudo apt-get install mercurial 命令安装。

Windows 操作系统: 到 Mercurial SCM 下载并安装。

配置 Mercurial

在操作系统中你自己的 HOME 目录下创建一个 .hgrc 文件,内容如下:

(注:Windows 操作系统中的 HOME 目录可使用 C> echo %UserProfile% 命令获得。)

# This is a Mercurial configuration file.
[ui]
username = ben.skyiv

使用 Mercurial

bitbucket.org 网站注册一个用户,我注册的 username 是: ben.skyiv

然后就可以点击网页右上角的“Create new”按钮来创建一个新的代码库(repository),比如叫做:  BigInteger 。

然后就可以接着干活了:

$ cd ~/Projects
$ hg clone https://ben.skyiv@bitbucket.org/ben.skyiv/biginteger/  BigInteger
$ cd BigInteger
$ (在这个目录下干些活儿,也可以把原来现成的东东拷贝到这个目录下)
$ hg add
$ hg ci -m "Init"
$ hg push

这样就 OK 了。

使用 SSH

按照 UsingSSH 中要求在 bitbucket.org 网站中的 Account 页面设置好 SSH 公钥(Public key)。注意,这相当于在你的 Account 中开了一扇带锁的门,而你的 SSH 私钥就是这扇门的钥匙。所以,请务必保管好你的 SSH 私钥。然后就可以用

$ hg clone ssh://hg@bitbucket.org/ben.skyiv/biginteger/  BigInteger

代替上一节的 hg clone 命令,这样,在执行 hg push 命令时就不需要输入密码了(当然,这取决于你的 SSH 密钥的设置)。

注:Windows 操作系统请参阅“对话 UNIX: 在 Windows 上使用 Cygwin”,安装 CygwinOpenSSH。然后在 .hgrc 文件的 [ui] 节中加入以下语句:ssh = C:\cygwin\bin\ssh -C

进一步的阅读

请务必看看:A tour of Mercurial: the basicsUnderstanding Mercurial

还可以看看:hgrc: configuration files for Mercurial

posted on 2009-11-29 20:43 银河 阅读(602) 评论(3) 编辑 收藏

评论

#1楼 2009-12-06 10:45 kyo-yo      
也是看了Tower Joo 的文章才开始研究HG.。
感觉非常的不错。。。。
但是在公司的项目中使用HG好像还比较难
 回复 引用 查看   

#2楼 2009-12-09 14:50 hong_ginger      
我也在研究mercurial..现在遇到问题了。。。
我的QQ: 980445169。。。。 skype:hong_6063
看到评论后,,找我哦。。。谢谢。。
 回复 引用 查看   

#3楼[楼主] 2009-12-10 07:50 银河      
@hong_ginger
我也是刚刚开始学习使用 Mercurial 。如果你有什么问题,可以在这里发表评论,或者发邮件到:
s k y i v b e n ( a t ) g m a i l ( d o t ) c o m
我们互相学习、交流、讨论。
谢谢!

 回复 引用 查看