How to setup BitBucket on MacOS X

BitBucket

BitBucket on a Mac

Setting up BitBucket on a Mac can be troublesome with Mercurial, SSH, etc… all needed in order to get going. So, here’s a quick step-by-step guide to setting up a BitBucket Code Repository on Mac OS X.

First, you will need to setup and install the following before we get started with BitBucket itself:

Install Mercurial

BitBucket is a version code repository that is build on the open-source Mercurial source code management (or SCM) software. For Mac OS X, Mercurial can be downloaded and installed from here: http://mercurial.selenic.com/downloads

Create an SSH KeyPair

In order to avoid typing credentials all of the time as well as having compression and other benefits, I prefer to authenticate to BitBucket over SSH. So, we need to create an SSH KeyPair (Public + Private keys) to use with BitBucket. To do this we will leverage the Mac OS X Terminal app (or your favorite terminal shell) and follow these steps:

  • Launch Terminal app (or your favorite terminal shell)
  • Change directory to your user folder’s (~) SSH folder (.ssh):
    $ cd ~/.ssh
  • Generate a new SSH RSA Keypair:
    $ ssh-keygen

    At the first prompt, enter “bb_rsa” to generate the keypair specific name.

    At the second prompt (and the subsequent confirmation prompt), enter a unique passphrase for RSA keypair.

  • Load your newly created “bb_rsa” RSA Key
    $ ssh-add -K bb_rsa

    At the first prompt, enter in your unique passphrase for your RSA key that you established above.

  • Copy your newly created public key “bb_rsa.pub” into the clipboard.
    (NOTE: Make sure to include the “.pub” so that you copy the public key to the clipboard buffer and not your private key.) 

    $ cat ~/.ssh/bb_rsa.pub | pbcopy

BitBucket Setup

Setup a BitBucket Account

Add your SSH Key to your Account

  • Click on the “Account” link in the main BitBucket toolbar at the top of the page. Then, add your public key to the “SSH Keys” section of the Account page. To do this, paste your clipboard contents (which contain your public key from above) into the SSH “Add Key” text box and press “Add Key”

Create a BitBucket Repository

  1. Click the ‘Create new‘ button  on your Bitbucket home screen.
  2. Enter a name and description for your repository.
  3. Tick ‘Private‘ if you want to hide your repository from the general public, so that only selected people can see it.
  4. Click ‘Create repository‘.

Clone a BitBucket Repository to your Mac (“Downloading the Code”)

Let’s create a new directory on the Mac and initialize it for use withBitBucket. To do this we will leverage the Mac OS X Terminal app again (or your favorite terminal shell) and follow these steps:

  • Launch Terminal app (or your favorite terminal shell)
  • Change directory to your user folder (~):
    $ cd ~
  • Create a new directory for your source:
    $ mkdir bb_source
  • Change directory to this new folder:
    $ cd bb_source
  • Clone your BitBucket repository into this new directory (download code):
    $ hg clone ssh://hg@bitbucket.org/{username}/{repositoryname}

    *NOTE: The SSH address can be found within BitBucket by selecting your repository and clicking on the SSH link next to the HTTPS link

Add Files to your Local Mercurial Repository

  • Add files to your Mercurial SCM on your Mac:
    $ hg add
  • Then, commit the files to your Mercurial SCM on your Mac:
    $ hg commit -m "A comment goes here!"
  • More details on adding, updating, and deleting files into your local Mercurial repository can be found here.

Update Files in your Local Mercurial Repository

  • Just modify files on your local Mac and then enter:
    $ hg commit -m "A comment goes here!"
  • More details on adding, updating, and deleting files into your local Mercurial repository can be found here.

Pushing your Local Mercurial Repository to BitBucket

The last and most important step is to upload your code to the “cloud”… your BitBucket Repository.

  • To do this enter:
    $ hg push
  • More details can be found here.

Other Helpful Tools and Links

  • MacHG - MacHg is a free open source OSX GUI for the revision control system Mercurial. This allows you in a nice graphical way to manage a collection of files, to add things to the collection, to save a snapshot of the collection, to restore the collection to an earlier state and in general to work with the files. In my humble opinion it’s the best Mercurial client for OSX.
  • BitBucket Documenation - Bitbucket Documentation Home
  • TortoiseHG - TortoiseHg is the Windows-version of MacHG and provides a series of applications for the Mercurial distributed revision control system. It also includes a Gnome/Nautilus extension and a CLI wrapper application so the TortoiseHg tools can be used on non-Windows platforms.
  • Mercurial - Mercurial is a free, distributed source control management tool. It efficiently handles projects of any size and offers an easy and intuitive interface.
  • Generating SSH Keys OSX – Github’s guide to generating SSH Keys on a Mac.
Posted in Uncategorized | Leave a comment

This Week in Innovation – Jan 14th, 2011

Sites Site(s) of the Week

  • – TinEye is a reverse image search engine. You can submit an image to TinEye to find out where it came from, how it is being used, if modified versions of the image exist, or to find higher resolution versions. TinEye is the first image search engine on the web to use image identification technology rather than keywords, metadata or watermarks. It is free to use for non-commercial searching.

Articles Article(s) of the Week

  • C60 – Evolution of an ideaThe C60 concept was created to bring tangibility to the digital music experience. A card represents a song or a collection of songs. Placement of a card on the C60 table causes the music represented by the card to be played. Multiple cards placed on the table form a clockwise ordered playlist.

Videos Video(s) of the Week


TED Talks TED of the Week

  • Thomas Thwaites: How I built a toaster – from scratch – It takes an entire civilization to build a toaster. Designer Thomas Thwaites found out the hard way, by attempting to build one from scratch: mining ore for steel, deriving plastic from oil … it’s frankly amazing he got as far as he got. A parable of our interconnected society, for designers and consumers alike.
Posted in cloud, google, innovation, Uncategorized | Leave a comment

This Week in Innovation – Jan. 7th, 2011

Sites Site(s) of the Week

– This week is a-buzz with all of the latest gadgets and technology at the Consumer Electronics Show in Las Vegas… have a look at the official CES2011 website.


Articles Article(s) of the Week


Videos Video(s) of the Week

  • Android 3.0 – Honeycomb - A sneak peek at Android 3.0, Honeycomb, the next version of the Android platform, designed from the ground up for devices with larger screen sizes, particularly tablets.
  • Christmas 2.0 - A viral video telling the story of Jesus’ birth to a new generation has resulted in a huge blessing for the small Portuguese ad agency that created it.

TED Talks TED of the Week


Dilbert

Posted in cloud, innovation | Leave a comment

Top 5 Google Chrome Extensions…

Top 5 Google Chrome Extensions came out this week and I would hate to see my Chrome Browser get slowed down by too many bloated extensions, so I will highlight the Top 5 early Chrome extensions out there that add the most functionality…

Posted in cloud, google | Tagged , , | 1 Comment