Sunday, June 19, 2011

Setup Bitbucket using SSH on Ubuntu

Bitbucket is a good alternate to Github which provides free unlimited private hosting upto 5 collaborators. It uses Mercurial which is DVCS.

I prefer SSH over HTTP to access work on my repository. The steps to setup are as follows:
  1. Signup on Bitbucket (Obviously)
  2. Create a repository after login using Repository -> Create New Repository
  3. Install mercurial on your local system
    1. sudo apt-get install mercurial
  4. Create the Mercurial Configuration File
    1. vi ~/.hgrc
    2. [ui]
      editor = vi
      username = FIRST_NAME LAST_NAME <email>
      
  5. Create SSH Key if not present on your local system  using the following steps
    1. ssh-keygen
    2. The generated key files are stored under ~/.ssh
  6. Upload the ~/.ssh/id_rsa.pub file to Bitbucket under Account -> SSH Keys
  7. Setup the Key in Ubuntu
    1. chmod 644 ~/.ssh/id_rsa.pub
      ssh-agent bash
      ssh-add
  8. Now clone the repository from remote server
    1. hg clone ssh://hg@bitbucket.org/<username>/<repository>
  9. To add and commit code use the following commands
    1. hg add <file/folder>
      hg commit -m '<commit message>'
      hg push
     
    A very good reference for basic Mercurial is
http://hgbook.red-bean.com/read/mercurial-in-daily-use.html
     


    No comments: