I've recently started work porting the design of the DE0 Nano serial communications protocol to Lattice Semiconductor's iCE40 HX8K Breakout Board (A First Impression review of the breakout board is coming soon). Now since I wasn't sure how much change would be involved, in porting the design, I thought now would be a good time to start using Git (git-scm.com) for versioning control religiously. Hence, I installed a Git server on a Synology DiskStation DS215j Network Attached Storage (NAS) (First impression review also coming soon) and got on with it. Here's how the exercise unfolded.
Git can be considered to be a version control system that stores data, as a set of snapshots of a miniature filesystem. However, unlike other version control systems, most Git operations operate on data stored locally. Hence, once a Git repository stored on a Git server has been downloaded, or "cloned", locally there is no need for any more interaction with the networked server, until the cloned work is committed back to the server. This is an important aspect of Git, as there is no network latency involved when using Git commands on a locally stored project folder.
Bearing this in mind once I had set up my Git server on the Synology NAS, a process which is described below. I began work on the conversion project on my desktop and performed Git commands to "add" any changes before "commit"ting them to the server. A partial snapshot of the project directory, cloned locally, is shown below:
Setting up the Git Server
In this section I demonstrate how I setup the Git Server and a user account, using the Disk Manager Station (DSM) 5.1. The DSM is a package installation manager provided by Synology and is available as part of the NAS initial installation process. It is the preferred route used to install what are essentially Linux packages on the NAS, as the packages are optimised for Synology's products.
Hence, for this type of exercise the first thing to do is to install the Git Server package found in the DiskStation manager's package center. The installation process is a point and click exercise and you generally and only need to follow the on-screen prompts. If you struggle during this part of the exercise then it's fair to say that using a Git Server probably isn't for you!
Next, you should enable the SSH Service by navigating to the Terminal and SNMP directory service. Select a port number to allow access through a Firewall and you should be good to go.
Now, a lot of demonstrations on how to setup a Git Server, found on the Internet, tend to suggest that a user account is created especially to access Git repositories on the NAS. Hence, I did the same by creating a user called, unimaginatively, gituser. For this exercise the gituser has been made a member of the user group only.
The gituser will be the sole user that will be given access to the Git repository, apart from the root user of course and any other accounts that have administrator rights. To use the Git Server the gituser account must be given access to it. This is done by enabling access to the server by navigating to the main menu and then the Git Server account, as can be seen in the screenshot, above.
We want to store our project files, on the NAS, in the directory /volume1/Repository/. To do so we create a shared folder Repository with the directory permissions shown in the screenshot, above. These just seem like common sense options, to me, as they provide another layer of security to protect your precious data and Intellectual Property (IP) from the inevitable visitors that will try and share it.
Using Git Server - The Business End of Things
Up to now we have not really used Git or the Git Server for that matter, as we have merely setup the server and an account to use it. To actually use it we need to login as the root user and create a Git repository. I logged into the NAS, using the admin account, as seen below.
The only contents of the Repository folder at this stage is a #recycle folder subfolder, created because we Enabled Recycled Bin when we created the Repository folder. The next thing to do is to create a git project folder and initialise it an empty or "bare" repository, as shown below.
At this point I should have recursively changed the ownership of the DE0NanoCommsProject.git directory and all of its siblings to gituser and the group to users, by using the command chown -R gituser:users DEONanoCommsProject.git. Instead I got the following errors:
A stumbling block? It took me a while to work out that you need root privileges to issue the chown command. Hence, the sudo command must be used. Doh! Maybe Git is not for me. LOL!
To test if we can clone our empty repository we need to log into the project folder from a Mac or Linux terminal or even a Windows client like Cygwin, for example.
A drama and crisis all at the same time. Time to start up the PS4 and play a couple of games of FIFA 15, to help think things through. However, I couldn't take the risk of playing FIFA, because I only need to take 1 point from the remaining two games of the season to gain promotion to division 4 for the first time, ever.
Hence, it was look-at-the-ceiling head scratching time. If only the solution was on the ceiling, maybe the writing was on the wall? It wasn't however and as a hunch I went back into the DiskStation manager and checked the file permissions of the Repository folder. Low and behold I had not granted the gituser permission to Read or Write to the Repository folder.
Ticking the appropriate check box solved the problem, as can be seen in the screenshot, above.
That's all that is required to get up and running with the NAS Git server and from this point onwards all of the standard Git commands apply. However this is not the end of the story, as SSH stills needs to be setup "properly" and the method of using Git as a numeric versioning scheme still needs to be demonstrated. These and other topics will be the subject of the next parts of this series. ... and finally, I gained promotion to Division 4 of FIFA 15 Seasons, due to my amazing managerial skills and due to the fact that my opponent, playing as Juventus, quit after 5 minutes into the first-half. Also, to add icing to the cake I won the last game 3-0 to take the Division 5 title. More soon.