Git with Synology DiskStation

When developing private software projects, you not always want to push it to Github right away if you’ve got the hopes to make some bits of money out of it, right? But just keeping your Git repository on your local disk isn’t the best choice either. If you happen to have a server at home, you should use that to backup your repository. Of course you should do that the Git way, i.e., set up a bare repository and use that as your origin remote to push to.

That’s particularly easy if you own a Synology DiskStation. Not too long ago, an official Git Server installation package was made available:

DSM "Git Server" package description

Enable SSH and user grant access rights

After installation, you get access to a simple GUI where you can allow local users to access Git over SSH:

Git config

Tick the checkbox for your user and press Apply. To make this work, you also need to enable SSH access to your DiskStation. For that, head into the Control Panel, navigate to Terminal & SNMP and tick the Enable SSH Service checkbox. For setting up a bare Git repository, you have to log in over SSH (assuming diskstation is a proper hostname):

$ ssh root@diskstation

Windows users can use PuTTY.

Remote Git repository setup on the DiskStation

This is how to set up my_repo for user sascha on /volume1 (Diskstation default, don’t worry):

$ mkdir -p /volume1/git/my_repo
$ chown -R sascha. /volume1/git/my_repo
$ cd /volume1/git/my_repo
$ git init --bare

Then you can log out from your DiskStation again. On your local machine, you can either directly clone this newly created repository:

$ git clone ssh://sascha@diskstation:/volume1/git/my_repo

Or add it as a remote to your already existing git repository and push your master branch to it:

$ git remote add origin ssh://sascha@diskstation:/volume1/git/my_repo
$ git push --set-upstream origin master

That’s it.


6 thoughts on “Git with Synology DiskStation

  1. Is it possible to handle access right for differents user, I tried to lock access to shared folder to a guy, but he is still able to access the clone command on my repo inside this shared folder ?


  2. Hi,

    A little bit late in the game but could you tell me what’s the `–set-upstream` argument is and do in your last line (`git push –set-upstream origin master`) ?


  3. It basically means that your local master branch will “linked” to the master branch of the origin remote. All pushes and pulls on your local master go to its counterpart automatically. Git help push has more details

  4. Thanks.
    Now, stupid question number 2 :
    I have changed the default port for ssh on my Syno. I know how to acccess the NAS via ssh on the new port via `ssh -pXXX myUSer@myNAS`(where XXX is the new port number.
    What I don’t now, though, is how to affect the port change in the `git remote add origin ssh://sascha@diskstation:/volume1/git/my_repo`line (I suppose it needs the new portsomewhere ) ?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s