Link a database to Git

Experience the ultimate control and precision in database development with dbForge Source Control, the dynamic SSMS add-in. Designed to cater to the needs of database developers and teams, it's your trusted companion for version control and database change management.

This article provides a straightforward step-by-step guide on connecting your SQL Server database to Git using dbForge Source Control, including essential prerequisites.

  • Version control integration: Connect with popular version control systems like Git, GitHub, GitLab, Azure DevOps, Bitbucket
  • Real-time collaboration: Enable multiple developers to work simultaneously on database objects, ensuring efficient teamwork
  • Effective conflict resolution: View conflicts and address data and schema inconsistencies visually
  • Easy deployments: Effortlessly generate deployment scripts from version-controlled objects for smooth transitions between environments
  • Simple commit and revert: Deploy changes with full awareness of dependencies
  • Comprehensive change tracking: Be aware of who, when, and why made changes to database objects

Prerequisites

Starting from version 2.2, dbForge Source Control supports Git for Windows client versions 2.28.0 and above. To check your Git version, simply use the git --version command. This allows users to work with all possible connection and authentication types, as this task is delegated to the Git client. Before trying to connect your database to Git, make sure that you have Git for Windows client installed on your machine.

Before you link a database to a remote repository, make sure to clone the repository. You can host it on platforms like GitHub or GitLab. Alternatively, create an empty local repository using the git init --bare command.

Work with a local Git repository

dbForge Source Control requires a local clone of a remote repository to work effectively. It does not support direct interaction with remote repositories; instead, you must first clone the repository locally and then work with this clone.

To work with a local Git repository, perform the following steps:

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

2. Start Windows Command Prompt (CMD).

Note: To change the disk drive and navigate to the empty folder you created, in the Command Prompt, use the cd command.

3. Type git init --bare create an empty local repository.



Create an empty local repository

4. Switch to a different folder and clone the local repository using the command git clone <pathToMainRepo>. Remember to add a period at the end of the command, ensuring the repository is cloned into the folder you've created. Omitting this will result in the creation of an additional subfolder.

Note:<pathToMainRepo> is the path to the main repository you created locally when executing the git init --bare command.



Clone Git repository

5. In the designated folder, run the following CMD commands:

  • git commit --allow-empty -m initial to create an initial commit.
  • git push to push the changes to the remote repository.


Run git commit and git push

6. Link dbForge Source Control to that folder in the following order:

  • In Object Explorer, right-click the database you want to link to source control and select Source Control > Link Database to Source Control.
  • In the Link Database to Source Control dialog that opens, click + in the Source control repository field to open the Source Control Repository Properties dialog.
  • In the dialog that opens, do the following:
    • Select Git from the Source Control system dropdown list.
    • In the Repository folder field, click the More options icon to select the repository folder.
    • Optional: In the Repository name field, you can change the name of the repository folder.
    • Click Test to verify that the database has successfully been connected to source control.
    • Click OK to close the Source Control Repository Properties dialog.

    And finally, in the Link Database to Source Control dialog, select a database development model and click Link.



dbForge Source Control
Security

Is the connection secure when dbForge Source Control connects to a Git repository?


dbForge Source Control connects to Git using the standard Git client for Windows, which supports current security protocols, including TLS 1.2. Secure connections are established when the server both supports them and requires them. For instance, if a repository’s address begins with HTTPS and the server stipulates the use of TLS, the connection will comply with these security requirements. The choice of security protocol is determined by the server’s configuration, not by dbForge settings.

Conclusion

dbForge Source Control is an essential SSMS add-in for database development that offers seamless version control integration and facilitates real-time collaboration. It simplifies complex tasks like conflict resolution, script generation, and change tracking. With its support for popular version control systems and an emphasis on efficient teamwork, dbForge Source Control is an indispensable tool for modern database management. Start enhancing your database project management today by downloading dbForge Source Control.

Video Tutorial: Collaborating on a Database Project Using dbForge Source Control

As a final recommendation, we invite you to view our comprehensive video tutorial, which illustrates the effective use of the dbForge Source Control add-in for collaborative efforts on a single database project. This tutorial provides valuable insights and practical tips to enhance your team's productivity and coordination.