Git Server

Git is an open-source distributed version control system, which allows you to maintain software source code, documents, or any type of file on a computer with speed and efficiency. With Git, you can collaborate with different groups of people simultaneously with relative ease.

To create a Git repository:

  1. Sign in to DSM using an account with administrative privileges.
  2. Go to Control Panel > Terminal & SNMP > Terminal then enable SSH service.
  3. Go to Control Panel > Shared Folder and create a shared folder for Git repositories.
  4. On your computer, enter the command below to access Synology NAS via SSH:
    ssh [Synology NAS admin user name]@[Synology NAS IP address or hostname] -p [The port number of SSH]
    For example, you can enter:
    ssh myadminuser@192.168.1.2 -p 22
  5. Enter the command below to change the current directory to the shared folder you created in step 3:
    cd /[Volume name]/[Shared folder name]/
    For example, you can enter:
    cd /volume1/mysharefolder/
  6. Enter the command below to create a folder on your computer for the Git repository:
    mkdir [Folder name]
  7. Enter the command below to change the current location to the new folder:
    cd [Folder name]
  8. Enter the command below to create a Git bare repository under the folder you created in step 6:
    git init --bare

Note:

To allow users to use Git:

  1. Sign in to DSM using an account with administrators’ privileges.
  2. Go to Control Panel > Terminal & SNMP > Terminal, and enable SSH service for users to access Git repositories via SSH.
  3. Go to Control Panel > User & Group and create a user. Grant Read/Write permission of the Git repository shared folder to the user.
  4. Go to Package Center > Installed and open the Git Server package.
  5. Allow the user to access repositories via git-shell.

Note:

To clone Git repositories from DSM to a local directory:

  1. Install Git on your computer.
  2. Access the Git repository located on your Synology NAS. To successfully access the repository, please make sure:
  3. Enter the command below to clone the repository from DSM to the local directory:
    git clone ssh://[Your username]@[Synology NAS IP address or hostname]:[Your repository]
    For example, you can enter:
    git clone ssh://mygituser@192.168.1.2:/volume1/mysharefolder/myrepo1
  4. You can access the repository from the local directory with the command below:
    cd [Your repository]
    For example, you can enter:
    cd /volume1/mysharefolder/myrepo1