How to use ApexSQL Source Control with local file system repositories

Applies to
ApexSQL Source Control

Summary
This article explains how to create and use Git, Mercurial, and Subversion local file repositories with ApexSQL Source Control

Description

The local file system repository is intended for single users as a solution for the application testing and evaluation purposes. The advantages of a local repository are easy setup and fast local data transfer since it bypasses the source control server. However, it is not recommended as a long-term solution because it is difficult to share it with other team members and setup a proper security for the repository.

The database can be linked to the local file system repository with ApexSQL Source Control through local file access protocol.

Local file system repositories can be created for Git, Mercurial, and Subversion source control systems using the command line interface (CLI) or TortoiseSVN/TortoiseHg free client tools.

Git

To create a local file system repository:

  1. Download and install Git source control system with Git Bash
  2. Start Git Bash
  3. Type git init –bare <directory> to create a bare repository directory

Example: “git init –bare /c/repository” will create an empty repository in C:/repository

Alongside with the repository directory, a .git subdirectory in the repository root will be created, containing all of the necessary metadata. For more information, see the Git documentation.

Quick tip icon

Quick tip:

The local file system repository can be created by cloning the existing remote Git repository accessible via HTTP, HTTPS and SSH protocols. To do so, in Git Bash type git clone <url> <directory> (example: git clone https://github.com/test /c/repository)

Mercurial

To create a local file system repository using TortoiseHg:

  1. Download and install TortoiseHg
  2. In Windows Explorer, right-click on a folder where the repository will be created and from the TortoiseHg submenu, select the Create Repository Here option:

  3. In the New Repository dialog box, specify the repository name in the Destination path box and click the Create button:

Alternatively, a Mercurial repository can be created from the CLI. To do that:

  1. Start Command Prompt
  2. Type hg init <directory_path> (example: hg init E:\Mercurial\Repository)

Subversion

To create a local file system repository using TortoiseSVN:

  1. Download and install TortoiseSVN
  2. Create a new folder on a local hard drive to set it as a local repository
  3. Right-click on the newly created folder and from the TortoiseSVN submenu, select the Create repository here option:

    Quick tip icon

    Quick tip:

    Make sure that the folder is empty and not write protected to prevent errors during the repository creation process

  4. A repository will be created inside the new folder and a confirmation dialog will appear:

To determine whether to create a directory structure within the repository, check out the Subversion documentation section called “Repository Layout”.

Quick tip icon

Quick tip:

It is strongly recommended to use an empty folder as a local repository, or a folder with the same structure as ApexSQL Source Control uses

Alternatively, Subversion repository can be created from the CLI. To do that:

  1. Open the Command Prompt interface
  2. Type the following command svnadmin create <directory>

    Example: svnadmin create C:\SVNRepository

TortoiseSVN will set a custom folder icon when creates a repository so that local repositories can be easily identified, unlike when the repository is created using the CLI.

To link the database to the local file system repository with ApexSQL Source Control:

  1. In SQL Server Management Studio, right-click a database from the Object Explorer pane, and from the context menu, select the Link database to source control option:

  2. In the Connection type step of the Source control wizard, specify source control system:

  3. In the System login step provide Repository path in the form of:

    Quick tip icon

    Quick tip:

    Repository path should be specified in the same manner, regardless of the source control system that is used

    file:\\<LocalPathToRepository>\<repository>

    Quick tip icon

    Quick tip:

    In case of using the local repository, username and password are not mandatory

Additionally, the user can create a new folder in the repository.

After the linking process is completed, ApexSQL Source Control will store all the necessary script files in the local file system repository.

FAQs

Q: What are the pros\cons of using a local file system repository?

A: Pros: Fast, easy adjustments and if there is no need for extra security it can be used inside internal LAN.

Cons: Anybody can delete the repository, by accident. Security can be jeopardized in case access is enabled over Internet.

Q: Is it possible to use network drive as a local file system repository?

A: Yes, it is possible to use network drive as a central store point without a problem, in case all developers are in the same LAN environment.

Q: Why can’t other source control systems that ApexSQL Source Control supports be used with a local file system repository?

A: Because only Git, Mercurial and SVN support creation of the file system repository which can be accessed using the file protocol.

Q: Which database development models can be used with a local file system repository?

A: Both models, Shared and Dedicated can be used with a local file system repository.