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.
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