New project in Bitbucket and Source Tree

source_treeAbout a half year ago we started using Git for version control of our websites and applications. We use Bitbucket to store our online repositories because they offer an unlimited number of free private repositories. This in sharp contract with Github which lets you only save five private repositories. Although we are pro-opensource code, the websites and apps we develop for our clients should remain private off course.

At first we did all our Git development using the command line. Although this was a choice in order to learn Git with the command line and the Git messages you receive are quite verbose, I kept on forgetting the commands you do not use every day. For example the commands used when setting up a new project, coupling the remote repositories to be tracked by the local ones and so on. Therefore, the next step was to start working with the free desktop client of Bitbucket which is called Source Tree. This is an easy to use interface to do all your Git stuff like setting up a new project, creating and deleting branches, staging, committing, pulling, pushing, merging etc.

This post will be about setting up a new project. It is probably more of a reminder for myself, but please, read on!

Assumptions & prerequisites

You have Git installed locally and downloaded and installed Source Tree app. You have a Bitbucket account (we also created a team to be able to work together) and some code in a local Git repository that you want to make available in Bitbucket.

Creating a repository in Bitbucket

Click on the light blue button Create in the Bitbucket menu to create a new repository.
Screen Shot 2014-11-13 at 12.01.30Choose the owner. Here you can choose your own name or any team you belong to. The benefit of teams is that all team members see this new repository when they log in to Bitbucket. If you create a personal repository it is also possible to invite other developers but you must do this manually. So I choose for owner plintsites (the name of our team). Choose a name (I choose test) for the repository and optionally add a description. Since we are talking about Git you choose that as the repository type and you can check Issue tracking and a Wiki.

Put some bits in the bucket

Screen Shot 2014-11-13 at 12.05.45The repository is empty so it is time to add some bits to the bucket. Remember, we already had some code in a local Git repo right? It is time to get that in Bitbucket. We will do this using the command line (just this once ;-)). The nice thing is, though, that the syntax is given to you by Bitbucket. So go ahead and click the link under Command line I have an existing project. The following code pops up and you run this from the directory your local repo resides in using the command line:

cd /path/to/my/repo
git remote add origin
git push -u origin --all # pushes up the repo and its refs for the first time
git push -u origin --tags # pushes up any tags

This may take a while depending on the amount of code yo already had in your project. At last: the code arrived in Bitbucket and it is possible to be pulled by another developer.

Clone the repository in Source Tree

Assuming your co-developer has Source Tree installed and an active Bitbucket account (and is invited by you for this repository), these are the steps to clone the remote repository to the local machine. First open Source Tree en click the button Remote. A list with remote repositories is shown. Find the one you are looking for and click on the small button at the right to Clone the repository.

Screen Shot 2014-11-13 at 12.15.09

Fill in the field for the Destination Path or use the … button to explore with finder and Source Tree does the rest. The next step is coding, staging, committing and pushing.

Happy coding!

Mijn Twitter profiel Mijn Facebook profiel
Pim Hooghiemstra Webdeveloper and founder of PLint-sites. Loves to build complex webapplications using React! Latest post
Did js-beautify break the internet?

Leave a Reply

Your email address will not be published. Required fields are marked *