Sunday, May 15, 2011

Setting up a GIT server on Ubuntu

I have all my code in a GIT repository on my home machine.
Everytime I wanted to deploy the code for my pet project site I used to fire up winscp and copy the code manually to the server. Well, as anyone would guess this was not only inefficient but error prone. Also reverting back to an old version just in case I ran into issues used to be a series of deletes & copies of directories.

GIT to rescue
The "divineness" (you kidding me ! this is not a word !!), anyways, let me start again. The "divineness" in me finally made me create a git server on my hosting server (slicehost). BTW, 2 words for my hosting company(its long due), I wanted to have a linux server with full root access and do whatever I wanted. Maximum flexibility and control. Plus I wanted 24x7 support. Slicehost has both, their customer service is awesome !! I always log into their chat and ask them stuff and they go above and beyond everytime.

K, no further digressions, lets get dirty

Setting up you git server on Ubuntu
The first thing you need to do is to install git on the Ubuntu server. That's a breeze:
apt-get install git-core

Now lets setup a directory where git server will run out of -
mkdir /opt/gitrepo
cd /opt/gitrepo

Initialize git :
git init --bare
The --bare flag tells git that this is a brand new directory where git will be setup

Pushing to this repository from your home machine.
For the purpose of this post, lets assume I have my git running at c:\myrepo also I'm writing this from a windows machine, so I'm in my gitbash

k, the first thing is telling your machine the server location.
git remote add origin ssh://
Lets go over the command :
git remote add origin : I'm adding the origin of this repository as
ssh:// : 
ssh is the protocol
planet : this is the user name : Well this is the name of your slice where you are setting the git server
/opt/gitrepo : The location of the server repo base we setup earlier

Push it to the server
Now lets push the master branch on your home machine to the server :
git push origin master
** master = This is the master branch on the home machine.
If you want to push some other branch, say "currentWorkingBranch", then type :
git push origin currentWorkingBranch

Once you run the command you'll see compression of files and pushing them off to the server, the output will end with something like :
* [new branch]      master -> master
* [new branch]      currentWorkingBranch -> currentWorkingBranch

Verify on the server
On your server, go to /opt/gitrepo and type :
git branch
and you should see the branches you have pushed till now.

Remember, if you list the directories you WON'T see your code files.
Again, you WON'T see your code files.
Why ? - Because this is a server. You files are present internally and there is no working branch, hence you will get an error if you try this :
git status

Now you'll want to extract data out of this server - Read clone
So lets do that.
For testing create /temp/temprepo
in that just type :
git clone /opt/gitrepo/ /tmp/temprepo/
Now list the files and you'll see your code in /tmp/temprepo

btw, if you want to checkout a particular branch from the server, then first create a branch where you want to have the data :
git branch branch-April2011 origin/branch-April2011
now checkout this branch :
git checkout branch-April2011
That's it you should have cloned the data only for that repository

The irc channel #git on freenode is very helpful, I'd suggest checking it out if you get stuck.
Ofcourse you can ask me about this.

Wednesday, May 11, 2011

Types of personalities in a company

Listened to a great Podcast by Bill Gross @ Stanford university
After starting about 75 companies in 15 years (likes of Picassa, CitySearch, etc..) he had some great insight into types of people.

I found his definition of personalities a lot practical than various others I've come across by others.

I'll try to convey it here for people who don't want to listen to the whole 110 mins. (I highly highly recommend it)

Every person in the company is a blend of the 4 given below, finding the right balance is crucial and any one trait taken too far is detrimental :


  • Entrepreneur
  • Producer
  • Administrator
  • Integrator

Quick description
  • Entrepreneur : The innovator. Simple enough.
  • Producer : The person who actually builds things. It might be a website, a tool, whatever, but this person is the one who actually believes in hands on building stuff. Not just talk.
  • Administrator : The bureaucrat. He wants to put processes in place. Its a good thing ! This person understands  that when things really scale they can't survive if there isn't a process in place.
  • Integrator : He is a more people person ( read balanced). He knows the Producers mostly want to get things done and the Administrator is always trying to put processes in place that slow him down, and all this while the Entrepreneur is building things in air and wants it to be practically embodied. The Integrator puts everyone in a room, brings the best out of each, draws agreement and makes sure no one kills each other 8-) According to Bill this is one of the very important qualities of a CEO.

Great encouraging talk. Thanks Stanford.