Corporate Git – git

August 28th, 2010

previoushomenext


We’ve arrived to the most exciting part: You may not be aware, but by now the “bar.baz” machine is a minor git-hub!

You’re still Master Foo, you already have an exciting project stored on your machine in git in “~/eggs/” (you’re a Cygwin user, obviously). The eggs are becoming popular within the corporation and you want to involve more developers. Here is how it goes:

MasterFoo@foo ~$ ssh git@bar.baz
Last login: ...
git@bar ~$ mkdir eggs.git && cd eggs.git
git@bar ~/eggs$ git --bare init
Initialized empty Git repository in /home/git/eggs/
git@bar ~/eggs$ exit
logout
connection to bar closed.
MasterFoo@foo ~$ cd eggs
MasterFoo@foo ~/eggs$ git remote add origin ssh://git@bar.baz/~/eggs.git
MasterFoo@foo ~/eggs$ git push origin master

A bare repo has no working tree. So the magic stuff is not in “~/eggs/.git/” but directly in “~/eggs.git/”. It’s a convention that bare repositories’ names should end with the “.git” extension.

Older versions of git allowed pushing into a non-bare repo. But push just updates the history and the HEAD, leaving a) the index and the working files intact b) the local repo-user in a severe shock. So it’s no more allowed from git 1.7.0. Bare repos are just a push-pull hub.

Now even the local MCSE can collaborate with you if he uses Cygwin and gives his public key to the owner of “bar.baz”.

MCSE@mcse ~$ git clone ssh://git@bar.baz/~/eggs.git
Initialized empty Git repo...
...
MCSE@mcse ~$ cd eggs
MCSE@mcse ~/eggs$ echo '# Even MCSEs love Unix' >> eggs
MCSE@mcse ~/eggs$ git commit -a -m "MCSEs love Unix"
MCSE@mcse ~/eggs$ git push origin master

Now you probably see how, with a bit more sophisticated handling of users, you could build your own Guerrilla GitHub. All you need is Cygwin. Have fun!

Comments are closed.