Problem
I want to create a personal micro-Github on a server, but how does one talk to git on the server in an elegant manner? Would it be wise to the send commands to the git-shell using PHP's exec
? Would I be talking to git directly? To understand the idea, let's talk about it for a few seconds.
How it should work
The idea is that I want to create a GitHub-like application that will allow users to manage multiple repositories and browse repositories. It will be required that git is installed on the server for it to become a git server. And in order to allow the aforementioned GitHub-like features, I imagine that I should wrap git in an API layer which shall serve as a data-access layer. This way, the application may use git to do git things, and shall allow the application to accomplish useful things:
Please note: language choice is not limited to PHP. I only used PHP because of its exec()
function which helps to highlight to the questions in this case.
// Instantiate a git object
$git = new Git();
// Connect to a git server
$result = $git->connect("0.0.0.0","username","password");
// Create a bare repository in the filesystem
$repo = $git->init("name","/home/pwd/user/name.git");
// Clone a repository
$repo->clone("username","host","repository")
// Commit to the repository
$repo->commit($fileset,"message","long message");
Question
The question becomes this: beneath the Git
objects and abstraction, how would I talk to git on the server? Would I be sending commands to the git-shell using PHP's exec
? Is there another way that I can speak with git elegantly?