Version control is a nice way to keep track of work. As a bonus you've got automatic backup and you can trace major fsck-ups. In my honest opinion code versioning is a must. However plain-text versioning can work as well. I'm moving further and further towards text-only computing, so it is natural step forward to version my textfiles also.
I've got a little catalog of text notes, passages etc. that I was storing on my VPS for some time now. I access this catalog from different computers (all in my total control, hence with secure connection over SSH) to note stuff. It is far from perfect as I needed stable internet connection to do so. Of course that's not really a problem in a big city. However internet connection also means lots of distractions!
Here I will describe my approach to this problem - setting up a GIT repository on my VPS. With git repo I can clone, version and merge text files from different computers and do my work locally without internet connection (and awful distractions!).
Prerequisites
- Server with administrative privileges.
git
andssh
literacy.
Git installation and configuration
Note: I'm having Debian VPS so all instructions will be noted with accordance to this system.
Install git
:
$ sudo apt-get install git
Create git
user and configure it to use git-shell by default:
$ sudo useradd -m -d/home/git git
$ sudo echo '/usr/bin/git-shell' >> /etc/shells
$ sudo usermod -s /usr/bin/git-shell git
$ sudo su -s /bin/bash - git # use /bin/bash explicitly as we default to git-shell for security
$ mkdir git-shell-commands
$ exit
Grant access to trusted computers
Do not forget to add your ssh keys to git's user ~/.ssh/authorized_keys
.
Create local bare repository
We need to create bare repository in git user's home catalog. Bare means that it will only store git objects, so we can say this is server-side part of repository.
$ sudo su -s /bin/bash - git
$ mkdir REPONAME.git
$ cd REPONAME.git
$ git --bare init
$ exit
Add remote to local repository, push and get to work
After all this work we can create repository locally, add our newly created bare repository as a remote and begin normal git workflow:
$ mkdir REPONAME
$ git init
$ git remote add origin 'git@SERVERNAME:REPONAME.git'
May the open source be with you!