Bitbucket is a web site which is owned by atlassian company. It provide free private git repository service, your source code will not be exposed to public when saved in their repository. It also provide a bitbucket server for you when you want to install the repository server on your own machine, but bitbucket server software need some fees.
Source tree is a free git client tool which is provided by bitbucket. It support both Mac and Windows. If you want to use git tool for Linux, you can read article How To Use SmartGit In Ubuntu. This article will tell you how to setup git respository in bitbucket website and how to use source tree to manage it.
1. How To Create Repository In Bitbucket.
- First you should register a bitbucket account, or you can use google account to login to bitbucket.
- After you login, click Create ( + ) button in left panel list.
- Then click Repository menu item in the popup menu list.
- Now it will popup Create a new repository window, input the repository name, check This is a private repository checkbox in Access level section. Select your Version control system as Git or Mercurial, i select Git radio button. Click Advanced settings link to expand advanced settings area. Select the repository used language from the Language drop down list.
- Then click Create repository button to create it, after that you will see the new repository dashboard like below.
2. Install & Setup Source Tree.
- Download and install source tree for mac or windows. This step is very straight forward.
- When you run the source tree tool for the first time, it will show you the popup registration dialog window. The Bitbucket Cloud option will let you connect your source tree client to the bitbucket repository that you just created in bitbucket website. The Bitbucket Server option will let you connect source tree client to you own bitbucket server.
- Click the Bitbucket Cloud button, it will open a web browser to display bitbucket login page. You can login to it with either your own bitbucket account or google account.
- After you login successfully, you will see below Registration complete! dialog, click Continue button.
- Then it will jump to Preferences dialog, just click Done button in it.
- After some while, it will open a window which list all your repositories created in bitbucket website.
- You can click the Clone button to clone and download the repository data to your local machine directory. When you click the Clone link at the end of each line, it will popup below dialog. The Source URL value should not be changed, you can select different Destination Path in your local machine. Then click Clone button to start clone.
- When the clone process complete, you will see source tree’s main window like below. If you create a new file such as hello in local folder /Users/songzhao/testrepository, this folder is also the repository managed local root folder, then you can see there is a commit ready in source tree main window.
- Click Commit button at top left corner, input commit description and check Push changes immediatlely to origin/master checkbox, then click Commit button to commit the changes to remote bitbucket repository server.
- When the commit process complete and success, it will show Completed successfully in the popup commiting dialog, otherwise it will show you the error messages in that popup dialog to tell why the commit fail.