August 27, 2011

Mercurial using BitBucket and Eclipse

If the project is already created in Eclipse, but not in mercurial repository, then:

(1) Create a repository in BitBucket.
(2) Go into shell, and clone from BitBucket which is empty.

e.g. If I have created non-mercurial project in local eclipse called "hello_world":

$ mv hello_world hello_world.bak
$ cp -r hello_world.bak hello_world
$ hg clone https://bitbucket.org/BBUSER/hello_world
http authorization required
realm: Bitbucket.org HTTP
user: BBUSER
password: 
destination directory: hello_world
no changes found
updating to branch default
0 files updated, 0 files merged, 0 files removed, 0 files unresolved

(3) Then move or copy those files from the local project directory into the BitBucket cloned directory.


$ cd hello_world
$ hg add
adding ....
[ommit]

$ hg ci -u BBUSER
$ hg push

(4) Remove hello_world project from eclipse (make sure to have a backup) and from disk.
(5) In eclipse's menu -> New -> Other -> Mercurial -> Clone Existing Mercurial Repository, then click <next> button.
(6) In next dialog, enter URL to the BitBucket repository (get this when the repository was created, or go  to the site and find out),  username/password.
(7) Click next, next, finish.

...there should be an easier way...

No comments: