Using Bitbucket With Visual Studio 2015

In this article, we are going to learn how to use the Bitbucket version control system with Visual Studio 2015. One good feature of Bitbucket is that if you have a small team of friends who want to work on a common project and want to share source code with one other, the Bitbucket is for you.

“It’s Free for a Small team up to 5 Users and its Unlimited private repositories”.

Next, we can use Bitbucket as a backup for all applications which we create for learning and doing R&D.

Bitbucket with Visual Studio
Bitbucket with Visual Studio

Pre prerequisite for Application

Visual Studio 2015

Create Bitbucket Account

First, create a free account.

For creating an account, visit https://bitbucket.org/account/signup/ site.

Bitbucket with Visual Studio

After entering Email id, next, click on the Continue button.

After clicking on Continue button, you will see 2 text boxes asking for full name and password. Enter your details; then do captcha verification and finally, click on Continue button.

Bitbucket with Visual Studio

After clicking on Continue button, it will send an email to the account which you have entered for verification.

Bitbucket with Visual Studio
Email Verification 
Bitbucket with Visual Studio

After clicking on Verify email address button it will ask for a unique username for Bitbucket Cloud, enter your Unique name and click on continue button.

Bitbucket with Visual Studio

Wow, we have finally created a Bitbucket Account.

Bitbucket with Visual Studio

Now we have created a Bitbucket account let’s create a repository.

Creating New repository

For creating new repository click on Create a repository button available on the dashboard.

Bitbucket with Visual Studio

After clicking on Create a repository button a new screen of Create a new repository will appear to you.

Bitbucket with Visual Studio

Steps for creating New repository

  • For Creating repository enter repository name; for demo purposes I have entered the name “myfirstrepository”.
  • Next, we are going to create a Private repository for doing that we need to check the checkbox of Access level.
  • Next, do you want a README file in the repository? Then choose the drop down accordingly; there are 3 options in it. If you do not want any option then choose “No”.
    1. Yes, with a tutorial (for beginners)
    2. Yes, with a template
    3. No
  • Next Version Control system there are 2 options available in that we are going to choose “Git” for this demo.
    1. Git
    2. Mercurial
  • Next entering Description for repository if you want.
  • Next Forking in this you will find 3 options;  for demo purposes I am going to choose “Allow only private forks”
    1. Allow only private forks
    2. Allow forks
    3. No forks
  • Next, in project management, there are 2 options. We are not choosing any options. For details of both options to read the given below notes.
    1. Issue tracking
    2. Wiki
  • Next language (Programming language) if you know in which Programming language your project is going to develop then you can choose a Programming language for this repository.
  • For the next integrations you want to enable with HipChat then you can choose this option.

Finally, click on Create repository to create “myfirstrepository” repository.

Notes for details

What is HipChat?

HipChat is a web service for an internal private online chat and instant messaging. As well as one-on-one and group/topic chat, it also features cloud-based file storage, video calling, searchable message-history and inline-image viewing

Referenced from:- https://en.wikipedia.org/wiki/HipChat

What is Forking?

Forking is to take the source code from an open source software program and develop an entirely new program.

Referenced from:- http://whatis.techtarget.com/definition/fork

What is Wikis?

When you add a repository to Bitbucket Cloud, you also get a wiki. The wiki is a simple place to keep documents. Some people use it as their project home page. The wiki is a Mercurial/Git repository, so you can clone it and edit it like any other source files, for example, take a look at the TortoiseHg wiki on Bitbucket Cloud.

What is Issue tracking?

When you add a repository to Bitbucket Cloud, you also get an issue tracker. This is the place to track your project's feature requests, bug reports, and other project management tasks. We keep the Bitbucket issue tracker very simple and yet somewhat flexible. It has just a few configurable fields (component, version, and milestone) – you can use them any way you want.

Referenced from:- https://confluence.atlassian.com/bitbucket/

Snapshot after creating repository

Bitbucket with Visual Studio

Now if you click on “myfirstrepository” repository you will see Overview page.

In that page, you will see “Get started with command line” heading.

Under that, you can see 2 options.

  1. I have an existing project
  2. I'm starting from scratch

In this part, we are going to expand “I'm starting from scratch” option and then inside that option, we are going to copy Git URL:- https://[email protected]/demoSai/myfirstrepository.git which we are going to use in upcoming steps.

Bitbucket with Visual Studio

Now we have completed creating the repository; next we are going to create an MVC application in Visual Studio and then that application we are going push it to “myfirstrepository” repository.

Creating MVC Application

Open New Visual Studio 2015 IDE.

Bitbucket with Visual Studio

After opening IDE just, next we are going to create MVC project for doing that just click File - inside that New - Project.

Bitbucket with Visual Studio

After choosing a project, a new dialog will pop up with the name “New Project”. In that, we are going to choose Visual C# Project Templates - Web - ASP.NET Web Application. Then, we are going to name the project as “DemoMVC”.

Bitbucket with Visual Studio

After naming the project we are going click on OK button to create a project.

A new dialog will pop up for choosing templates for Creating “ASP.NET Web Application” in that template, we are going to Create MVC application. That's why we are going to choose “MVC template” and next click on OK button to create a project.

Bitbucket with Visual Studio

After clicking on OK button it will start to create a project.

Project Structure

Bitbucket with Visual Studio

After creating project next, we are going to add source control.

Adding Source Control (Git)

Bitbucket with Visual Studio

After adding to Source Control for acknowledging you can see Output window.

Bitbucket with Visual Studio

After adding Source Control next, we are going to Make a change in View to Commit changes to Bitbucket repository.

Bitbucket with Visual Studio

After making changes in view next click on Team Explorer Window.

Choose Team Explorer Window

After choosing this window you will see your project in Local Git Repositories.

Bitbucket with Visual Studio

Now click on DemoMVC project from Local Git Repositories.

After clicking on DemoMVC project from Local Git Repositories you will see a new window with 4 options

  1. Changes
  2. Branches
  3. Sync
  4. Settings

    Bitbucket with Visual Studio

Now we are going to click on Changes view because we have made changes to project which we need to commit to the repository.

After clicking on Changes view you will see a text area asking for Commit Message.

Enter a message describing the commit, and select Commit All button.

I am going to enter “Edited Index View” Message and finally click on Commit All button.

Bitbucket with Visual Studio

After clicking on Commit button, it will create a commit locally.

Bitbucket with Visual Studio

Now click on “Sync” link of Message.

Bitbucket with Visual Studio

After clicking on Sync link a new window will be seen in that you can see “Publish to Remote Repository” option just click on “Publish Git Repo” button.

Bitbucket with Visual Studio

After clicking on “Publish Git Repo” button a textbox will appear asking for URL, here we are going to add URL to Bitbucket Repository.

This URL is available on your Repository overview page.

URL :- https://[email protected]/demoSai/myfirstrepository.git

Snapshot of repository Overview page

Bitbucket with Visual Studio

After copying Bitbucket Repository URL, we are going to paste it into the textbox.

Bitbucket with Visual Studio

Finally, click on Publish button to Publish this project to Bitbucket.

But at  thefinal step Bitbucket will authenticate your account and ask for credentials, enter valid credentials and click on ok button to publish.

Snapshot of Bitbucket Authentication before publishing repository

Bitbucket with Visual Studio

Now we have published your source code to Bitbucket account.

To see changes, click on Source menu.

Snapshot of after publishing repository

Bitbucket with Visual Studio

To see all Commit Details, click on Commits menu.

Snapshot of Commits

Bitbucket with Visual Studio

Finally, we have learned how to use Bitbucket with Visual Studio 2015 in a step by step way. I hope you have liked this article.


Similar Articles