Using Bitbucket and Mercurial

15
Visit Bitbucket.or g Bitbucket.org can host code repositories. Public repositories are free. Private repositories are free if sharing with up to 5 people. Bitbucket uses Mercurial (hg) as well as git

Transcript of Using Bitbucket and Mercurial

Page 1: Using Bitbucket and Mercurial

Visit Bitbucket.org

Bitbucket.org can host code repositories.

Public repositories are free. Private repositories are free if sharing with up to 5 people.

Bitbucket uses Mercurial (hg) as well as git for version control.

We will use Mercurial.

Page 2: Using Bitbucket and Mercurial

Log in as gramenerClick on the “Log in” link at the top to log in.

The username is “gramener”.

The password can be obtained from [email protected]

Page 3: Using Bitbucket and Mercurial

Start a project

If you’re starting a new project, click on the “create repository” link on the top right.

Page 4: Using Bitbucket and Mercurial

Fill in the details

Type a project NameSelect PrivateChoose MercurialSelect Issue trackingSelect WikiChoose LanguageType a Description

Optionally, add a Website

Page 5: Using Bitbucket and Mercurial

Visit the site

The repository is now created.

It can be accessed at https://bitbucket.org/gramener/<name>

Currently, it contains no data

Page 6: Using Bitbucket and Mercurial

Clone a project

First, install cygwin with Mercural (hg) selected.

Clone an existing or newly created project by typing on the command prompt:

hg clone <project-url>

This may ask you for your ID (gramener) and your password.

Page 7: Using Bitbucket and Mercurial

Add files

Create or copy the project files into the cloned repository.

Here, I am copying files I already created into the repository.

You may use Windows Explorer to copy, or Notepad++ to create. Any other tool is fine as well.

Page 8: Using Bitbucket and Mercurial

Commit changes

hg status tells you the status of each file. Now, nothing’s tracked.

hg add file tells hg you want to commit file. It has not yet committed

hg commit commits only added files into the local repository. Bitbucket still doesn’t know of this yet.

Page 9: Using Bitbucket and Mercurial

Push changes

hg push tells hg to send the changes to bitbucket.

Only at this point will others be able to see your change.

This means that you can commit changes offline, locally, and push all your local commits when you go online.

Page 10: Using Bitbucket and Mercurial

Changes pushed

After hg push, you will be able to see your files on bitbucket.org

Page 11: Using Bitbucket and Mercurial

Email notification

You can receive a mail when someone commits a change.

In Admin, click on Services, and choose Email.

Type in your email ID and Save settings.

Page 12: Using Bitbucket and Mercurial

Ignore files

If you want to ignore specific files, create a .hgignore file.

Type in a list of regular expressions matching the files to ignore.

abc$ matches all files ending with abc. ($ stands for the end.)

Page 13: Using Bitbucket and Mercurial

Pull changes first

Before committing files, first pull other people’s changes into your repository.

ALWAYS.

hg pull copies them from bitbucket to the local repository.hg update copies from local repository to your folder.YOU MUST RUN BOTH

Page 14: Using Bitbucket and Mercurial

Add / change files

hg add any new files to the repository.

hg commit any existing or newly added files to the local repository.

Make sure you type a descriptive message with –m"…"

hg push committed changes to bitbucket.

Page 15: Using Bitbucket and Mercurial

View differences

On bitbucket, you can browse and see the exact lines that were changed in every commit.