首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件开发 >

Bitbucket 施用介绍

2013-01-26 
Bitbucket 使用介绍[ui]username John Doe john@example.com?2. Working on an existing Mercurial pr

Bitbucket 使用介绍
[ui]username = John Doe <john@example.com>?2. Working on an existing Mercurial project$ hg clone http://selenic.com/hg mercurial-reporeal URL is http://www.selenic.com/hg/requesting all changesadding changesetsadding manifestsadding file changesadded 9633 changesets with 19124 changes to 1271 filesupdating to branch default1084 files updated, 0 files merged, 0 files removed, 0 files unresolvedThis will create a new directory called mercurial-repo, grab the complete project history, and check out the most recent changeset on the default branch.

?

$ cd project/$ hg init # creates .hgMercurial will look for a file named syntax: glob*.orig*.rej*~*.otests/*.errsyntax: 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 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 --afterhg 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