Using BitBucket for Source Control

Source: Internet
Author: User
Tags visual studio 2010

If you are a professional software developer, chances are you have varous source code projects on your hard drive. You have those backed up, right? Nowadays, with SkyDrive and GoogleDrive, and DropBox fighting over who gets to hang onto your files, you do have options. however, if you want to actually truly outsource your source control repository, bug tracking, and documentation, you have option for that too-it's www.bitbucket.org

BitBucket (as of this writing) allows unlimited private repositories, with up to 5 people that you can share those private repositories with. For me, that is a pretty sweet deal! To get this going, here is what you need to do:

Step 1: Install Git for Visual Studio 2010

Go into Extension Manager in Visual Studio:

Then click Online Gallery and search for "GIT ":

From what I gather, you need both of these items. the Git Extensions INSTALLThe command-line stuff and the Git Source Control Provider ties in "some" of the Visual Studio stuff, but doesn't seem to work correctly for me.

Step 2: Set up a BitBucket account

Navigate to https://bitbucket.org/and sign-up, it's free. Once logged in, you will have some options for creating your first repository.

Step 3: Create a repository on BitBucket

The menu navigation is pretty simple-go into the screen that let's you create a new repository (https://bitbucket.org/repo/create as of this writing ). from here, you chose the name (which I make the same as my solution name), mark it as Private, I choose Git for the type, and I also like to turn on Issue Tracking and Wiki in case I need them. I might have something like this:

OK, so now we have Git installed locally and we have a repository up on BitBucket.

Step 4: Wire up your local repository to the remote one

Open up a command line. navigate to a root directory where you want all of your BitBucket projects-I chose C: \ _ BitBucket. this will be your local repository. in this local stream, you will make all your changes. at some point, you can then commit those changes and "push" them up to bit bucket.

Before we do that, we have to associate that BitBucket repository with our local directory. so, from that root directory (don't create a directory for this project), run the command that it tells you on the main repository page of your project, for example:

Git clone https: // MyUserName@bitbucket.org/MyUserName/sedersoftware. sampleproject. git

You shoshould see something like this:

C: \ _ BitBucket> git clone https: // MyUserName@bitbucket.org/MyUserName/sedersoftware. sa
Mpleproject. git
Cloning into sedersoftware. sampleproject...
Password:
Warning: You appear to have cloned an empty repository.

C: \ _ BitBucket>

This is true, you did clone an empty repository. so, under that C: \ _ BitBucket directory, you shoshould now have a sedersoftware. sampleproject. under that, you probably want to add a \ bin, \ docs, and \ src-and under \ src is where you wocould create your solution.

Step 5: Create or copy your solution to your local repository

If you already have source, simply copy it into C: \ _ BitBucket \ sedersoftware. sampleproject \ src \-or use Visual Studio to create a new project there:

Either way, get your source to that directory.

Step 6: Add files to your local repository

Now, we need to "add" these files to the local repository. now, you might have luck using that Git plug-in for visual studio, but I couldn't get it working. the good news is, the syntax is pretty easy from the command-line. here's what I do from the C: \ _ BitBucket \ sedersoftware. sampleproject directory:

Just a 'git add. 'and 'git commit-m "Added files"'-that adds these files to the local repository. Now, we have to push them up to BitBucket

Step 7: Push your local repository up to BitBucket

At this point, your project is "checked in" to your local repository, sitting on your hard drive. we now need "push" these files up to BitBucket. to do that, we need to a one-time step, to make these pushes easier. let's create an alias for the full URL of our project.

Git remote add myProject https: // MyBBUser@bitbucket.org/MyBBUser/sedersoftware. sampleproject. git

This will create an alias called "myProject" that points to that big URL. You get that URL from the main page of your repository, on www.bitbucket.org.

You then type:

Git push-u myProject master

Where "myProject" is the alias we created a minute ago and the "master" is the default name of our branch. this command prompts you for your bitbucket password, and it will push your files up:

And sure enough, on BitBucket, I can my push-AND all my source files are up there now too:

Step 8: Updates from now on...

The good news is, from this point on-making updates is a bit easier. let's say you 've ve modified some files, you 've added some files and now you are ready to save everything. you need to do a "git add. "to add any new files to the local repository, you need to do a "git commit" with a comment to "check the changes in"-then just a simple "git push"-will push to the same place you pushed last time. it will prompt you for a password, but aside from that, this just works nice and simple.

So, open a command-line, navigate into the project directory (e.g. C: \ _ BitBucket \ SederSoftware. SampleProject) and type:

  • Git add.
  • Git commit-m "Commit message goes here"
  • Git push

And that's it! There is of course much more to Git-including "ignoring" certain files for example. you can buy e that on your own. in the meantime, this will get your source off of your hard drive and into an offsite (and free) source code repository.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.