Home > Work > Uploading an Existing Local Git Repository to BitBucket.

Uploading an Existing Local Git Repository to BitBucket.

I use BitBucket for all my recreational, educational, and at home programming projects.  I like that fact that you can have free, private repositories. BitBucket supports Git as well as Mercurial.

Typically, I will create a new BitBucket repository and then use the Git Bash shell or Visual Studio to clone the project from BitBucket and simply add files to the new local repository.  However, there are times when I will start a local repository first and later decide that I like the project and want to save it off to BitBucket.

This is the procedure I use to upload an existing local Git repository to BitBucket.

Step 1 – Create a New Git Repository on BitBucket.

newRepo

Step 2 – Open your Git Bash Shell and Navigate to the Location of your Git Repository

Note: The location to the .git file is the path we are looking for.

$ cd Source/Repos/MyProject/

navigateRepro

Step 3 – Add the Remote Origin

Note: You will need to the remote path to your repository you created on BitBucket.  You can find this URL on the Overview screen for your repository in the upper right corner of the page.

$ git remote add origin http://bit.ly/1PuVrG7

addOrigin

Step 4 – Push your Repro and All its’ References

$ git push -u origin –all

You will be prompted to enter your BitBucket password.

pushAll

Step 5 – Ensure all Tags get Pushed as Well

$ git push -u origin –tags

Again you will be prompted to get your BitBucket password.

pushTags

If all goes well you will see the “Everything up-to-date” message displayed in the Git Bash shell.

The procedure above will move the entire repository. That means if you created local branches, the those are moved up as well. It’s pretty cool really.  Once the remote origin is set you can commit changes locally and then use Visual Studio’s built in Git support, or the Git Bash to Sync your changes “to the cloud”.

sourceView

Happy Coding!

Chris Clements
I am a senior software developer and development team lead in Houston Texas. I am passionate about the “art” of software development. I am particularly interested in software design patterns and the principles of SOLID object-oriented code. I am an evangelist for test driven development. I love to think and write about my day-to-day experiences in the trenches of enterprise IT. I relish the opportunity to share my experiences with others.

From the wire to the presentation, I am holistic solutions guy. I have broad experience in client side technologies such as Javascript, Ajax, AngularJS, Knockout, and Bootstrap. I have extensive experience with MVC, MVVM, and ASP.NET Web Forms. I am strong in SQL Databases, performance tuning, and optimization. I also have a background in network engineering, wide-area and inter-networking.

This article has been cross posted from jcclements.wordpress.com/ (original article)