BitBucket (http://bitbucket.org/)是一家提供源代码托管服务的网站,之前免费提供一个私有代码仓库和无限的公共仓库,不过,2010年9月 被 Atlassian 收购了之后,开始提供无限制硬盘空间的免费服务,并且不限制私有代码仓库和公共代码仓库的数量。(网站也提供收费服务,不同的套餐,可使用的用户数不同, 但是,对于中小型团队来说,基本上没有什么差别,免费的服务已经基本足够使用了。)

主要的功能有:

1. 无限硬盘空间
2. 问题跟踪
3. 项目 Wiki
4. API 支持
5. 灵活的权限控制
6. 可自定义域名
7. RSS 修改历史
8. 自定义下载

BitBucket 的网站,采用 django(Python)开发,使用 Mercurial 作为 DVCS(分布式版本控制系统 – Distributed Version Control System)

Atlassian 是一家澳大利亚软件公司,创建于 2002 年,旗下有名的软件包括:
JIRA、Confluence 等。

用学校邮箱一认证就OK了。。。处理不到半小时。。。支持git、无限空间、私有项目也有无限协作者。。。碉堡了。。。http://dyao.iteye.com/admin/blogs/1770514/edit

学生是可以获得bitbucket的免费无限帐号

申请地址: 学生(http://www.atlassian.com/software/views/bitbucket-academic- license.jsp) 非盈利组织(http://www.atlassian.com/software/views/community-license- request.jsp)

 

1.Setting a username

The first thing you should do is set the username Mercurial will use for commits. It's best to configure a proper email address in ~/.hgrc 1 (or on a Windows system in %USERPROFILE%\Mercurial.ini) by creating it and adding lines like the following:

 

[ui]  
username = John Doe <john@example.com>

2. Working on an existing Mercurial project克隆代码到本地

 

If you have a URL to a browsable project repository (for example http://selenic.com/hg), you can grab a copy like so:

$ hg clone http://selenic.com/hg mercurial-repo  
real URL is http://www.selenic.com/hg/  
requesting all changes  
adding changesets  
adding manifests  
adding file changes  
added 9633 changesets with 19124 changes to 1271 files  
updating to branch default  
1084 files updated, 0 files merged, 0 files removed, 0 files unresolved

 

This will create a new directory called mercurial-repo, grab the complete project history, and check out the most recent changeset on the default branch.

 

3. Setting up a new Mercurial project本地提交

 

$ cd project/  
$ hg init           # creates .hg

Mercurial will look for a file named .hgignore 2 in the root of your repository which contains a set of glob patterns and regular expressions to ignore in file paths. Here's an example .hgignore file:

 

syntax: glob  
*.orig  
*.rej  
*~  
*.o  
tests/*.err  

syntax: regexp  
.*\#.*\#$

 

 ignore files排除上传文件

 

Init the repo:

$ mkdir test 
$ cd test 
$ hg init

Create a file

$ touch foo 
$ hg st 
? foo

Now create a .hgignore, in the root directory of your repo:

$ echo 'foo' > .hgignore

foo is now ignored:

$ hg st 
? .hgignore

Test your .hgignore file with 'status':

hg status         # show all non-ignored files
$ hg add            # add those 'unknown' files  
$ hg commit         # commit all changes into a new changeset, edit changelog entry  
$ hg parents        # see the currently checked out revision (or changeset)

本地提交

本地的改动(新增、删除或修改),可以随时进行提交。这里的提交与svn之类的集中式代码管理工具不同,并不涉及到与服务器的交互,只是将代码改动提交到本地。

对于新增的文件,需要先将文件加入本地库管理。命令如下:

hg add

然后执行提交命令如下:

hg ci

如果你是第一次提交,可能报下列错误:

abort: no username supplied (see "hg help config")

那是因为你还没有指定你的帐号信息,需要到本地库下面的.hg目录下找到hgrc文件,在里面加入一行,如下:

[paths]
default = https://tielei@bitbucket.org/renren_platform/renren-api-python-sdk

[ui]
username = tielei <xxxx@gmail.com>

上面hgrc文件中请指定你在bitbucket系统的用户名和email。

然后重新执行hg ci提交代码。

这时会弹出记事本(或其它编辑器)提示你输入提交log,如下:

增加一个README文件。

HG: Enter commit message.  Lines beginning with 'HG:' are removed.
HG: Leave message empty to abort commit.
HG: --
HG: user: tielei <zhangtl04@gmail.com>
HG: branch 'default'
HG: added README

保存后关闭该编辑器,则本地提交成功。

 

将改动push回远程库

 

首先查看一下本地库对应的远程库是哪个(可选):

hg path

输出类似下面的格式:

default = https://tielei@bitbucket.org/renren_platform/renren-api-python-sdk

这说明本地库直接指向了renren_platform的远程库。

下面我们查看一下,本地库上有哪些修改,是远程库上没有的(可选):

hg out

输出类似下面的格式:

comparing with https://tielei@bitbucket.org/renren_platform/renren-api-python-sdk searching for changes changeset: 1:9754f48ee839 tag: tip user: tielei <zhangtl04@gmail.com> date: Sat Mar 12 23:56:38 2011 +0800 summary: 增加一个README文件。

现在我们试一试将这个本地改动直接push回renren_platform的远程库:

hg push

中间会提供你输入你在bitbucket上的密码。

然后,你会发现,结果出错了!输出如下:

pushing to https://tielei@bitbucket.org/renren_platform/renren-api-python-sdk searching for changes http authorization required realm: Bitbucket.org HTTP user: tielei password: abort: authorization failed

 本地文件先删除后更新

hg remove --after
hg remove -A

 If you intend to do addremove and commit, it can be joined with '-A' option as shown here:

hg commit -A -m 'Commit with addremove'
hg push