Step 1. Sign Up for Bitbucket
- Sign up at Bitbucket.org.
Step 2. Create your Bitbucket Repository
Note: You can skip this section if you are joining an existing Bitbucket repository.
- Click the 'Create new' button on your Bitbucket home screen.
- Enter a name and description for your repository.
- Tick 'Private' if you want to hide your repository from the general public, so that only selected people can see it.
- Click 'Create repository'.
If you need more detail on adding new repositories, please read Creating a Bitbucket Repository.
Step 3. Download and Install Mercurial and its Dependencies
Note: You can skip this section if you are already using Mercurial.
- Get Mercurial and Python:
- Download and install each one separately:
- Alternatively, if you are on Windows you can download and install TortoiseHg. (This bundles Python and Mercurial.)
- Add or edit your Mercurial configuration file.
If you are on Windows XP, Windows Vista or Windows 7, you will probably need to add the file because it does not exist at all. The file should be at the following location:
- UNIX-based systems: ~/.hgrc
- Windows XP: C:\Documents and Settings\MY_NAME\mercurial.ini
- Windows 7: C:\Users\MY_NAME\mercurial.ini
Add your name, email address and preferred text editor to the configuration file, so that the file contains at least the content shown below:
Step 4. Clone the Bitbucket Repository to your Local Drive
- Open a command window and go to the local directory where you want to create your repository.
- Clone the repository.
- A new sub-directory appears, with the same name as the Bitbucket repository that you have cloned. The sub-directory contains a folder called .hg. That is your Mercurial repository, containing the files and metadata that Mercurial requires to maintain the list of changes you make. Here is its structure as seen in Windows Explorer:
Step 5. Work in your Local Repository
You will use the Mercurial commands to work on files in your local repository. See the Mercurial documentation for details. Here are the basics:
- Adding new files: Add or copy the file to your local project directory, then enter hg add to add all new files to the repository at the next commit.
- Editing files: Just edit the file in your local project directory and save your changes.
- Removing files: Delete the file from your local project directory, then enter hg remove to remove the file from the repository at the next commit.
- Committing your changes to the local repository: Enter hg commit at the command line. To include a commit message, use this syntax:
See our example in Working on Files in your Local Mercurial Repository.
Step 6. Push your Local Repository to Bitbucket
- Enter hg push at the command line prompt in your local project directory, to copy your files from your local repository to Bitbucket.
- When prompted for authentication, enter your Bitbucket username and password.
Other Useful Mercurial Commands
- Enter hg log to see the log of changes committed to the repository. For example:
More about Mercurial