Link a database to a Git repository in GitHub

GitHub is a web-based platform for software developers that facilitates the storage and management of code along with the tracking and control of code changes through Git repositories. GitHub simplifies collaboration among developers, allowing them to work together on projects and efficiently handle issues, bugs, and feature requests. In addition, it helps automate testing, build processes and workflows during deployment through integration with various CI/CD tools.

Prerequisites

  • Install Git for a Windows client on the machine you’ll be version-controlling a database.
  • Have a GitHub account.

The article covers the following topics:

Step 1: Create a new repository on GitHub

1. Sign in to your GitHub account.

2. In the upper-right corner of the page, click the + dropdown menu and select New repository.

Create a new repository on GitHub

3. On the Create a new repository page that opens, enter the name and optional description.

4. Select the visibility mode:

  • Public to make the repository to be visible to everyone on the Internet.
  • Private to restrict access to specific users.

5. Make an initial commit to the repository by selecting the options:

  • Add a README file: Create a README file containing the project description.
  • Add .gitignore: Select files to be ignored. The .gitignore file will have a set of ignore rules.
  • Choose a license: Grant permissions so users can use, change, and distribute the product.

The default name of the branch is main. If you want to change the name, go to the settings tab.

Note

If you import an existing repository, skip this step.

6. To keep the changes, click Create repository.

Step 2: Clone the repository using the command line

1. Create an empty folder on the disk of your computer where the local repository will be stored.

2. In the GitHub account, switch to the Repositories page and select the repository you want to copy to your computer.

3. On the <> Code tab, click the Code dropdown menu, select HTTPS, and click Copy to Clipboard to copy the URL of the repository.

4. Start Windows Command Prompt (CMD) and navigate to the empty folder you created.

5. In the Command Prompt, type the git clone command, paste the URL directory you’ve copied, and press Enter to create a cloned copy of the repository.

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

Copy the URL of the repository on GitHub

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

Alternatively, navigate to the main Database menu and select Link Database to Source Control.

2. On the Link page of the Link Database to Source Control wizard, click + in the Source control repository field to enter the source control repository properties.

Note

The previously linked repository will be selected by default.

3. In the Source Control Repository Properties dialog that opens, select Git from the Source Control system dropdown list and specify a path to the folder with the cloned copy of the repository in the Repository Folder field. You can specify a path to a subfolder in the repository (not .git).

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.

Link DB to Git

4. Optional: Click Test to verify that the database can be successfully connected to source control.

5. Click OK to apply the changes and close the Source Control Repository Properties dialog.

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

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

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

Linked DB

Step 4: After linking to the GitHub 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?