This post will describe how I set up and use my personal Git repository server.  Git is a time machine, and useful for tracking changes in source code, but also office documents. Git also provides a way of synchronizing remote files.  I have been using a personal version management software ever since I read a Lifehacker article about it. Git has some overhead.  This post is intended to describe my configuration and use.

Overview

The Git server and client will dialogue mainly through SSH.  The server uses a regular Unix account and file-system, not requiring anything more than SSH. In addition to the SSH access, I will put in place web interface to the files with password access.

My hosting provider currently is WebFaction. Although I am satisfied with them, I did lose all my files on the server once. Hence, I will take extra care with my backup strategy.

Since this is for personal use, I will set it up for https://git.mann.fr. I could, and may, also set up https://git.managence.com and/or https://git.seeshoot.com.

The files in the control system are mainly working files that are subject to change with a history I want to manage. I should take care to exclude the “.git” folder from other synchronization systems such as Dropbox, or historisation schemas.

The Server

I could use my regular Unix account for the SSH access with a certificate file.  I could also use a specific account for Git usage (more secure). I tend to think that password protection on the certificate would be useful.  I will create a Posix group c2git for this purpose (and perhaps a user of the same name).

I have set up the domain names mann.fr, seeshoot.com, managence.com to all point to the Webfaction name servers.  I will add git. to each domain and that will suffice for the ssh access. Web access will entail the creation and configuration of CGI git applications provided by Webfaction. Since I will put the repository data closer to the root, I will change the default directory.

My user directory at Webfaction is /home/chris2fr. Hence my repository directories will be /home/chris2fr/data/git/{mann.fr|seeshoot.com|managence.com|configmagic.com}[repositoryname].  The repository name should be globally unique and initiated with git init –bare repositoryname in a ssh terminal.  Assuming that I did create the c2git user, SSH access would then be c2git@git.managence.com/home/chris2fr/data/git/managence.com/repositoryname.git.  Below are the commands for initializing a repository:

cd /home/chris2fr/data/git/managence.com
git init --bare repositoryname.git

The web application I use, gitweb, requires a webapp and a repository base folder. I will name the webapps gitmannfr, gitseeshootcom, gitmanagencecom, and gitconfigmagiccom. I will change the repositories to point to /home/chris2fr/data/git/{mann.fr|seeshoot.com|managence.com|configmagic.com}.

I will backup from my local server with a script linked to an anachron job. The script will be located here : /opt/scripts/backupgit.sh. It will copy the contents of /home/chris2fr/data/git to /mnt/c43/c_backup/webfaction/data/git.

The Client

Client applications may be command-line, github, tortoisegit, etc. The website https://help.github.com/ provides excellent resources for that. Here are the commands I always forget:

git config --global user.name "c2git"
git config --global user.email "christopher@mann.fr"

Since I have a separate email account for each domain, I could use different email per repository:

git config user.email "christopher@mann.fr"
git config user.email "christopher@managence.com"
git config user.email "christopher@seeshoot.com"

As I noted before, the backup and synchronization are handled from Git, so we need to keep them independent of other systems.

The remote server and clone URLs are as follows:

git remote add origin ssh://chris2fr@git.seeshoot.com/home/chris2fr/data/git/seeshoot.com/wwwseeshootcom.git
git clone ssh://chris2fr@git.seeshoot.com/home/chris2fr/data/git/seeshoot.com/wwwseeshootcom.git

Remembering What is What

Git is a powerful tool. As with any power-tool, there are risks. I think two steps might help me keep track of the repositories I have and why I created them: anticipating the usefulness of the repository with a reason for creation of new repositories, and ; keeping an annotated index of the repositories, for example with a readme file in the repository itself.

Initial guidelines for setting up a repository are the folder being a website.  I will use the git only for websites and computer applications initially. I may or may not include binary files.

The readme file will depend on what gitweb supports.  README is a common use.

Conclusion

I have detailed in this web post how I intend on using my webserver as a Git file repository. I intend to follow this plan, and keep with the tool in some of my endeavors.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.