Setting up Git source control on a QNAP NAS

When I start a new project, the first thing I do is set up source control. Source control is key!
I know all my source code is safe and when I make mistakes I can easily do a rollback.

So why not take it serious and use Git?
GitHub is great, but it is not free when using private repositories. Tho I’m a big fan of open source, not all my projects are open source.

So I wanted to configure Git on my NAS, an old QNAP TS-410 (currently running on firmware 4.2.0).
This is how I configured Git for a QNAP NAS.

Install Git

First of all, install the QNAP package from the app center (currently version 2.1.0) and make sure it is turned on.

There seems to be something wrong with the QNAP Git package, because a manual action is required.
open a ssh connection to your NAS.

If you’re not familiar with ssh, you can download a client (f.e. putty) and open a new connection by entering the IP of your NAS.

now login with your admin account and enter the following command:

#  cd /usr/bin
#  ln -s /Apps/git/bin/git-upload-pack
#  ln -s /Apps/git/bin/git-receive-pack

This fixes an issue with the git-upload-pack and git-receive-pack not being found.

Hosting your repositories

Next, create a new share for your repositories.
I created a new share named ‘git’, but you’re free to choose.

Again, open an ssh connection and go to the just created share:

#  cd /share/MD0_DATA/git

if this does not work, the MD0_DATA folder is probably different. go to the /share folder and check the folder name with the following command:

#  ls -la

This will show a full list of all items and you can figure out what the right name is.

in the ‘git’ folder, enter the following command to create a new repository:

git init --bare NameOfMyRepository

This creates a new repository with the name ‘NameOfMyRepository’. It will automatically create a new subfolder with an identical name.

Cloning the repository

On your development machine, open your git tool and go to the directory where you want to work.
Now enter the following command:

git clone admin@YourIP:/share/git/NameOfMyRepository

This will ask for the admin’s password.
You can also use auto login by generating a ssh keyfile, but I do not want that for security reasons.

Once entered, the repository is cloned in a folder named ‘NameOfMyRepository’ and you’re good to go!

The Git controls integrated in VS2015 do not work with ssh yet, but the guys are working on it. You can read about it here


  1. Thanx this is where i was looking for!

  2. perfect thank you for the tutorial.
    how can I pull..
    I want to use source tree but it doesn’t work

    • Hi Simon,

      Thanks for your comment.
      What do you mean with source tree? Do you mean the integrated source control in Visual Studio?
      That isn’t supported yet. You can use the git command line to push and pull.
      This isn’t ideal, I know. I’m still trying to find a better solution for this.

  3. hi! thanks for sharing this. i tried it but got an error while trying to clone the repo under windows:
    $ git clone admin@
    Cloning into ‘MyFirstRepo’…
    FATAL ERROR: Network error: Connection refused
    fatal: Could not read from remote repository.
    Please make sure you have the correct access rights
    and the repository exists.
    the repo does exist. i never get asked for the admin password. reading your tutorial i thought i’d be happy if i could use another user than the admin. but it’s not working even with the most privileged user…

    • Hi chris,

      It is not mandatory to use the admin user, you can use a different user for it as long as it has enough privileges.
      I had the same error before I fixed the two git packages (git-upload-pack and git-receive-pack). Did fixing these packaging went correctly? No errors?

      • hi vincent, if by fixing you mean creating those two links in the /usr/bin directory, yes i did that 🙁 i’m not getting any errors other than that one i mentioned in my previous post. thanks for helping me out here 🙂

        • Same problem here on TS-251.
          All step done:
          – installed GIT 2.1.0 from QNAP repository
          – made link with no error
          – share created (name: git)
          – installed Git for Windows on my machine
          – issued command: git clone admin@
          Cloning into ‘testRepo’…
          fatal: protocol error: bad line length character: admi

          – issued command git clone admin:admin@
          Cloning into ‘testRepo’…
          Unable to open connection:
          Host does not existfatal: Could not read from remote repository.

          Please make sure you have the correct access rights
          and the repository exists.

          – issued command git clone admin@
          Cloning into ‘testRepo’…
          fatal: protocol error: bad line length character: admi (is not an error, it report me as admi and not admin)

          Where I am wrong?
          Some hint?

  4. Thanks for this clear tutorial! Just getting started with GIT. Is it correct that the repository on the QNAP does will not contain the actual source files?

    • Hi Jeroen, Thanks. It does actually store the file, they are stored in the objects folder. But it is not that simple. You cannot just browse through the objects folder and find all your files. The objects folder contains all your commit, trees, blobs and tags. They are all compressed with zlib, extracting them will give you your content. Though I should suggest you use the git tools to retrieve your files.

  5. Hi how can I make it public?
    calling from outside my local network?

    • Hi Simon, you could use port forwarding on your router and forward the ssh port to your NAS.
      This does bring a security risk, because this port will be open for everyone, so make sure you’ve got proper security

      • Okay, Thanks for the info,
        I am looking for an way to push it to an continous integration server.
        with an trigger or something.

  6. Bastien Desalle

    March 21, 2016 at 4:20 pm


    How can we do this without admin account ?
    Also how do a regular user can clone the repo ? I am having permission issue


    PS: Your Tutorial is awesome

    • Hi Bastien,

      Thanks! Just make sure your account has sufficient rights to your share and replace the admin account in the clone command with your account.


      git clone youraccount@YourIP:/share/git/NameOfMyRepository

      • Hi Vincent. Thanks for easy to follow tutorial. I made this work on my QNAP. But I ran into one problem.

        I cannot clone with non-admin account. I tried what you have mentioned above. It gives me a “permission denied” error. I don’t know much about the inner workings but could this be due to restriction on SSH access? Error log shows ” Login Fail (SSH)”.

        The user has RW access to the folder, I even changed owner. Nothing worked. Is this not possible or did I miss something?


  7. Patrik Nordelind

    March 28, 2016 at 2:03 pm


    I didn’t find the package on QNAP App center. But i found it here:
    and installed it manually. Then I could follow your guide. Thanks!

    • Hi Patrik,

      You’re right, the package seems to be gone from the QNAP package repository. I think it is removed by the Container station app. This should make it possible to install GitLab. Unfortunately, this app isn’t available for my QNAP NAS.
      Thanks for posting the link!

      • I just set up Gitlab using container station on mine. Easy! Just need to work out how to get gitlab to successfully send emails – for setting up new users!

        • Nils Andersson

          July 19, 2016 at 12:06 pm

          I am desperately trying to get gitlab to work on my QNAP TS-453 Pro. I have installed from Container Station, rebooted, then trying to go to the url:10080. Only response I get is
          Whoops, GitLab is taking too much time to respond.
          Try refreshing the page, or going back and attempting the action again.
          Please contact your GitLab administrator if this problem persists.

          Well, I am the admin… I have searched for this and the main issue I find is memory – but it has almost 8 GB available so that cannot be issue.

          Any ideas for what may be the issue?

  8. Strange each time I want to git clone (different days) I have to run command s
    # ln -s /Apps/git/bin/git-upload-pack
    # ln -s /Apps/git/bin/git-receive-pack
    over and over… it does work after these.

  9. Michael Templin

    July 25, 2016 at 9:08 am

    GIT has silently been removed from app store and seems no longer to be provided as an official Qnap app therefor you need to install it either manually or via qpkg/ipkg instead.

  10. I am having issues with finding the share folder and creating the subfolder

  11. Hi,

    I tried your way, downloaded app from dropbox, but even though I’ve installed git using appcenter, I get the message:

    -sh: git: command not found

    when trying to create the repo. Do you know how to solve this?

    Thanks in advance.

  12. Thanks, just what I was looking for! And that from a guy from Utrecht too!

Leave a Reply

Your email address will not be published. Required fields are marked *