In all my jobs I have used some kind of source control system. I started with VSS which is quite basic. Then I moved to Mercurial. At the beginning it didn't make any sense to me but one day I understood what Mercurial was all about. In my current job we use Git. After a few days playing with it I think it's more powerful and flexible than Mercurial. This video explains some differences between Git and Mercurial.
At home I have a NAS running FreeNas 9.3 and I have a bunch of Mercurial repositories. Now that I understand Git I want to migrate my projects to Git. But first I have to install a Git server on FreeNas. Here we go...
Jails are like virtual machines in FreeNas. It's recommended to install plugins or services in separated jails. To create a jail login into your FreeNas account and press Jails in the top menu. Select "Add Jails" and create a new jail. I called my jail "GitServer2". Go to advanced mode and write an IP address for your jail. If you want more information about jails you can check this link
I prefer to use SSH instead of the web-based shell that comes with FreeNas. Before activating SSH you have to create a new user in the Jail. Using the web shell (4th icon in the bottom of Jails menu in FreeNas) execute:
Follow the steps and make sure to add user to "wheel" group when you are asked to invite user to other groups.
Use the web shell to enable SSH in this jail. Edit the following file using "ee" editor:
Change sshd_enable parameter to yes:
To exit ee editor pres [ESC]. Make sure to save changes (option (a), then option (a) again). Then stop and start the virtual machine using the buttons at the bottom.
At this point you can close the web terminal. Open a terminal on your local computer (or execute Putty in Windows) and connect to your SSH account:
Your computer will ask you if you want to accept the new key for this connection. Type "yes".
I chose Gogs Git server which requires MySql. For installing MySql execute:
Choose "y" to all questions asked during the installation process.
Edit /etc/rc.conf file and add the following line
To exit ee editor pres [ESC]. Make sure to save the changes (option (a), then option (a) again).
Now open the MySql configuration file:
It should look like this:
Change permission of file executing:
Exit su mode by typing "exit". Then restart the jail as explained before. Reconnect to the jail via SSH. To test MySql server type "mysql". If the MySql prompt is displayed ( mysql> ) everything is OK so far. Check that MySql is listening in the right port by executing:
It should return 3306. Disconnect from MySql prompt by typing "exit".
Connect to MySql as root by typing:
Then create a new database, new user with password and grant permission to user for the new database:
You can easily install Git executing the following commands in SSH terminal:
Choose "y" to all questions asked during the installation process.
Gogs is one of many open source Git web managers. I chose Gogs because it seems to be very fast and user friendly. It doesn't have all features offered by other programs but for a small team it should do the work. To install Gogs we will use a script located here (execute it as root). More info can be found here.
To access "Install Steps For First-time Run" go to your browser and type the jail IP address and port 3000. In my case it would be:
In "Database Settings" select user, password and database generated in previous steps.
NOTE1: Make sure you have the right permissions for the folder you choose for repositories.
NOTE2: I found a fantastic Git GUI client called GitKraken. It's elegant, simple to use and multiplatform. I use Windows version at work and Linux version at home. It still in beta but it's under strong development process. I totally recommended!!!
NOTE3: It is recommended but not require to add a storage space mounted to the folder where repositories are going to be installed. This process goes outside the scope of this tutorial, but you can ask me to write more information.