Git Server

Git is an open-source, distributed version control system that helps you manage programming codes, documents, or other files on a computer in an organized and efficient manner. It also allows for easy collaboration with multiple groups of people.

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:

  • Please do not perform the above commands with root permission.
  • Owing to security concerns, Git Server no longer supports git-shell commands. To allow users to access repositories via git-shell, try using other container-based Git services.

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:
    • SSH service is enabled.
    • The user account you use has the permission for accessing the repository.
    • The user account you use has the Read/Write permission for the shared folder where the repository is located.
  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