Link a database to a Git repository in Azure DevOps

Azure DevOps is a cloud-based service that offers a rich set of tools for software development and code management. It includes a Git repository as a central hub for storing code and monitoring changes. Azure DevOps simplifies Git repository interactions with various features. For instance, you can clone a repository to your local machine, establishing a working copy that can be operated offline. You can also push changes from your local machine to the remote repository, instantly sharing updates with other team members.

Prerequisites

  • Have an Azure DevOps account.
  • Have an organization in your account. If you haven’t created it yet, you can create one in one of the two ways:
  • Have a project within the organization. If you don’t have one, Step 1 of the guide provides step-by-step instructions about how to do so.
  • Have appropriate permissions to create a repository, which are granted by default to project administrators.
  • Install Git for a Windows client on the machine where you’ll be version-controlling a database.
  • Have a Git repository created locally or cloned from the remote repository. If you haven’t done this yet, Step 3 provides a step-by-step procedure to clone a repository using the command line.

The guide covers the following topics:

Step 1: Create a project

1. Sign in to your organization https://dev.azure.com/YourOrganizationName and click + New project in the upper-right corner of the page.

Click a new project in Azure DevOps

2. In the Create new project dialog that opens, enter the project details:

  • In the Project name field, specify the name of your project.
  • Optional: In the Description field, add detailed information describing your project.
  • Under Visibility, select Public to make your project viewable for anyone on the Internet, or Private to make the project viewable only for the users you grant access to.
  • Expand the Advanced options and select the Git version control and work item process.

Create a new project in Azure DevOps

3. Click Create to create a project. Azure DevOps displays the project welcome page.

Step 2: Create a repository

1. Go to https://dev.azure.com/YourOrganizationName, hover over your project, and select Repos.

Click a new repository in Azure DevOps

2. On the top bar, select DevDemo > + New repository from the repository dropdown menu.

3. In the Create a repository dialog that opens, add the repository details:

  • In the Repository type dropdown list, select Git (the default option) or TFVC.
  • In the Repository name field, enter a name for your Git repository.
  • Leave the Add a README selected to create a readme file containing information about the code in your repository.
  • In the Add a .gitignore dropdown list, select the types of files to ignore that will be added to the .gitignore file. If you do not want to add the .gitignore file, select the default Add a .gitignore: None option.

4. Click Create to create the new repository, which will be initialized with the default main branch.

Create a new repository

Step 3: Clone a repository using the command line

You can create a local copy of a remote Git repository by cloning it into a local folder on your computer. Cloning a remote repository links each branch in your local copy of the repository with the corresponding branch of the remote repository.

1. Create an empty folder on the drive of your computer to store the local repository - for example, an azuredevops folder stored on the drive D.

2. Go to https://dev.azure.com/YourOrganizationName and select the project which repository you want to clone to your computer.

3. On the repository page, click Repos and select Files.

Clone a repository

4. In the upper-right corner of the Files page, click Clone to open the Clone Repository window.

5. Select the HTTPS connection protocol and copy a clone URL of the repository.

Copy a clone URL of the repository

6. Start Windows Command Prompt (CMD). If you need to change the disk drive and navigate to the empty folder you created, use the cd command.

7. In the Command Prompt, type git clone and paste the clone command with the repository URL to create a cloned copy of the repository in the local folder (azuredevops in our case), and press Enter.

Note

Specify a dot at the end of the command to clone the repository to the folder you have created. Otherwise, another subfolder will be created.

If you didn’t add any files to the repository when you created it for the first time, execute the following commands:

  • git commit --allow-empty -m initial

  • git push

Clone a repository in Azure DevOps

After the repository has been cloned to the folder on your local computer, you can link the database to source control using the Source Control tool available in dbForge Studio for MySQL.

1. In Database Explorer, right-click the database you want to link to source control and select Source Control > Link Database to Source Control.

2. In the Link Database to Source Control dialog that opens, click + in the Source control repository field.

3. In the Source Control Repository Properties dialog that opens, do the following:

  • From the Source control system dropdown list, select Git as a source control system.
  • In the Repository folder field, click More options icon More to add the repository folder located on your computer. In the Select Folder window that opens, select the folder, which is a local copy of your remote repository, and then click Select Folder.

Note

The repository folder name represents a path to the local copy of the remote repository and must not contain the URL of the remote repository.

  • Optional: In the Repository name field, you can change the name of the repository folder.
  • Optional: Click Test to verify that the database has been connected to source control.
  • Click OK to close the Source Control Repository Properties dialog.

Select the repository folder

4. Select a database development model: shared or dedicated.

5. Click Link to establish the connection between the database and source control.

Link a database to source control

The Refresh progress window opens automatically, showing the stages of the refresh operation. Once connected, the linked database gets the following icon in Database Explorer:

Linked DB

Step 5: After linking a database to the repository

If you are the first person to link this database, add the database objects to source control in an ‘initial commit’: go to the Local changes section, select the objects, and click Commit. For more information, see Commit changes.

If you linked a database that is already in source control, update your database to the latest version: go to the Remote changes section, select the objects, and click Get Latest, which is available only in the dedicated model. For more details, see Get the latest version.

Want to Find out More?

Overview

Overview

Take a quick tour to learn all about the key benefits delivered by dbForge Studio for MySQL.
All Features

All features

Get acquainted with the rich features and capabilities of the Studio in less than 5 minutes.
Request a demo

Request a demo

If you consider employing the Studio for your business, request a demo to see it in action.
Ready to start using dbForge Studio for MySQL?