For the purpose of this article, Bitbucket is chosen as a Git hosting service. In order to prepare the “communication” between Git hosting service and your application, the following steps need to be performed:
The first step is to create an account on Bitbucket if it’s not already created. The sign-up process is quite easy and it can be done by logging with Google account or creating a new account with e-mail and password:
Learn more about creating a Bitbucket account from this link.
Once the Bitbucket account is created, the next step is to create an empty repository.
In the main bar, at the top of the page where the browser will lead after creating an account, click the Repositories, and choose the Create repository option:
When a new page is opened, specify a Repository name, Access level and Repository type. Repository name and access level depend on the user’s preferences and, as already mentioned, Git will be chosen for the Repository type, but note that Bitbucket offers Mercurial as another repository type that can be created as well:
Additionally, by expanding the Advanced settings, additional options such as description, forking, etc., can be set for the new repository:
To learn more about Advanced settings, visit the following link.
Once everything is set, click the Create repository button to finish the process.
Also, if there is some code in an old repository, it can be used by clicking the Import repository in the top-right corner and the following window will be shown:
To import the old repository, provide its URL address, username and password and enter the new repository name below it. Once this is all set up, click the Import repository button and old code will be added to the new repository.
In the next step, browser will lead to the Repository setup page where an online repository path can be obtained.
Expand the I’m starting from scratch and copy the marked path that will be used for the repository path when connecting your application:
This is the Overview window after creating the new repository and from here navigation can be done to the Source, Commits, Branches, Pull requests, Downloads, and Settings tabs. All of these are accessible from the navigation tab on the left side:
For more information about getting started with Bitbucket cloud, visit the following link.
Examples for reviewing code/commits on Git repository
Since the new repository won’t contain any commits/code, the following examples are created after a SQL database was committed to the Git repository, so that the mentioned tabs contain actual information that can be reviewed.
In the Source tab, all folders under the repository root will be shown. Each folder can be considered as a different project and by changing the branch, different projects will be shown (if available):
If one of the projects is clicked (in this example MyProject), it will open a list of folders, named by the SQL database objects which were previously committed:
For example, click the Procedures folder and all committed procedures will be shown in the list:
Each of these procedures can be downloaded and edited locally or edited online.
In the Commits tab, each commit can be reviewed by clicking the commit code in the Commit column marked below:
When the commit code is clicked, all committed SQL object scripts will be shown and each one of them can be clicked to be reviewed or edited:
Learn more about commits and pushing changes from here.
As mentioned in the Source tab, branching the repository is available on Bitbucket and it can be used when testing certain procedure or function, for example.
When the Branches tab is clicked, the following window will show the main (master) branch and all other branches:
If any of branches is clicked, the new window will show all made commits (as in the Commits tab) and each commit can be also reviewed or edited:
Read more about branching a repository from here.
Q: Can I commit objects to a non-empty repository/project?
A: Yes. Objects can be committed to a non-empty repository/project, but if those objects have the same name as the ones in the repository, it can cause overwriting of repository objects.
Q: Is there a limit on the number of projects that can be created under the same source control repository?
A: The limit for the number of projects depends on their size because Bitbucket repository is limited to 1 GB. That means you can create as many projects as you want, but their combined size cannot exceed 1 GB.
Q: How can I check my current repository size?
A: You can check your repository size by clicking the Settings tab on the left side pane and find the current repository size under a repository name:
Q: Which version of Git does Bitbucket support?
A: You can find out the information about the latest supported version anytime by scrolling down on any page of the Bitbucket site and click the Version info in the footer:
Q: Are my repositories backed up by Bitbucket?
A: Yes, Bitbucket creates daily snapshot of your data and those snapshots are saved for seven days. Learn more about repository backups from this link.
He uses his spare time on tuning and styling of his car, playing video games, and fishing.
Nemanja is currently working for ApexSQL LLC as a Software sales engineer. He’s specialized in SQL database schema and data comparison and synchronization, and he helps customers with technical issues, providing DEMO presentations, and does the quality assurance for ApexSQL Data Diff and ApexSQL Diff.
View all posts by Nemanja Popovic
Latest posts by Nemanja Popovic (see all)
- Techniques to bulk copy, import and export in SQL Server - July 23, 2018
- SQL Server database continuous integration (CI) Best practices and how to implement them – Testing, processing and automation - January 31, 2017
- SQL Server database continuous integration (CI) Best practices and how to implement them – Source control - January 31, 2017