Git is one of those rare applications that has managed to encapsulate so much of modern computing into one program that it ends up serving as the computational engine for other applications. While the authors of Git probably expected front-ends to be created for Git, they undoubtedly never expected Git would become the back-end for, say, a chat client. And yet, that's exactly what developer Ephi Gabay did with his experimental proof-of-concept GIC: a chat client written in [Node.js](https://nodejs.org/en/) using Git as its back-end database. GIC is by no means intended for production use. It's purely a programming exercise, but it's one that demonstrates the flexibility of open source technology. What's astonishing is that the client consists of just 300 lines of code, excluding the Node libraries and Git itself. And that's one of the best things about the chat client and about open source; the ability to build upon existing work. Seeing is believing, so you should give GIC a look for yourself. Setup ===== GIC uses Git as its engine, so before trying GIC yourself, you need an empty Git repository to serve as the chat room and logger. The repository can be hosted anywhere, as long as you and anyone who needs access to the chat service has access. For instance, you can set up a Git repository on a free Git hosting service like Gitlab, granting chat users contributor access to the Git repository (they must be able to make commits to the repository, because each chat message is a literal commit). If you're hosting it yourself, create a centrally-located bare repository. Each user in the chat must have an account on the server where the bare repository is located. You can create accounts specific to Git with Git hosting software like [Gitolite](http://gitolite.com) or [Gitea](http://gitea.io), or you can give them individual user accounts on your server, possibly using git-shell to restrict their access to Git. Performance is best on a self-hosted instance. Whether you host your own or you use a hosting service, the Git repository you create must have an active branch, or else GIC won't be able to make commits as users chat because there is no Git HEAD. The easiest way to ensure that a branch is initialized and active is to commit a README or license file upon creation. If you don't do that, you can create and commit one after the fact: $ echo "chat logs" > README $ git add README $ git commit -m 'just creating a HEAD ref' $ git push -u origin HEAD Installing GIC ============== GIC being based on Git, you must install Git if you don't already have it. The application itself is written in Node.js, so you must also install Node.js and the Node package manager npm (which should be bundled with Node). The command to install these differs depending on your Linux or BSD distribution, but here's an example command on Fedora: $ sudo dnf install git nodejs If you're not running Linux or BSD, follow the instructions for installation found on [git-scm.com](http://git-scm.com) and [nodejs.org](http://nodejs.org). There's no install process, as such, for GIC. Each user (Alice and Bob, in this example) must clone the repository to their hard drive: $ git clone https://github.com/ephigabay/GIC GIC Change directory into the GIC directory and install the Node.js dependencies with `npm`: $ cd GIC $ npm install Wait for all of the Node modules to download and install. Configuring GIC =============== The only configuration GIC requires directly is the location of your Git chat repository. Edit the file `config.js`: module.exports = { gitRepo: 'seth@example.com:/home/gitchat/chatdemo.git', messageCheckInterval: 500, branchesCheckInterval: 5000 }; Test your connection to the Git repository before trying GIC, just to make sure your configuration is sane: $ git clone --quiet seth@example.com:/home/gitchat/chatdemo.git > /dev/null Assuming you receive no errors, you're ready to start chatting. Chatting with Git ================= From within the GIC directory, start the chat client: $ npm start When the client first launches, it must clone the chat repository. Since it's nearly an empty repository, that doesn't take long. Type your message and press Enter to send a message. ![](gic.jpg) As the greeting message says, a branch in Git serves as a chat room or channel in GIC. There's no way to create a new branch from within the GIC UI, but if you create one in another terminal session or in a web UI, it shows up immediately in GIC. It wouldn't take much to patch in some IRC-style commands into GIC. After chatting for a while, take a look at your Git repository. Since the chat happens in Git, the repository itself is also a chat log: $ git log --pretty=format:"%p %cn %s" 4387984 Seth Kenlon Hey Chani, did you submit a talk for All Things Open this year? 36369bb Chani No I didn't get a chance. Did you? [...] Leaving GIC =========== Not since vim has there been an application as difficult to stop as GIC. You see, there is no way to stop GIC. It will continue to run until it is killed. When you're ready to stop GIC, open another terminal tab or window, and issue this command: $ kill `pgrep npm` GIC is a novelty. It's a great example of how an open source ecosystem encourages and enables creativity and exploration, and challenges us to look at applications from different angles. Try GIC out. Maybe it will give you ideas. At the very least, it's a great excuse to spend an afternoon with Git.