Friday, July 8, 2011

git howto & Help

I faced some challenge to get started with git. Adding insult to injury I was behind firewall.
And while I started I found no straight forward information. Long assistance with Prof. Google ;-) I got some scattered help. So to make sure I never forget it I thought to keep it posted on my page.
Note: This is no tutorial but my meandering experiences and learning when I started to work with git.


I was working with gitorious so all my instruction are wrt gitorious.org
The first thing you ask is what is git. Well ask the Professor I mentioned above you will get loads of information.

Now after your first question got answered you might want to know how to get started with git?

So here is how you get along with it.
Step 1: install git. Run the following command as root.
Opensuse: zypper install git
Ubuntu: apt-get install git-core

Step 2: Generate ssh key. Run the following command.
ssh-keygen (enter few time if you wish to take default options)
You get some message like this in the end
Your public key has been saved in /home/<username>/.ssh/<someid or id_rsa if taken default>.pub

Step 3: Create an account in Gitorious
  • You will get logged into it once create (or login to your gitorious account)
  • Go to Dash Board
  • got to Manage SSH keys option
  • Click Add SSH key & you will find one text editable area
  • Go to a terminal and run cat /home/<username>/.ssh/<someid or id_rsa if taken default>.pub
  • paste this output to the text editable area.
  • Save it
  • After adding you might find a X (cross) under "Ready ?" row.
  • Refresh the page it will turn into be a tick option (It's for your confirmation. It's ok if this step is not done)
Now you can work with git.

Trouble-Shoot 1:: You might face problem in accessing the content (git clone ...). When you try first time you may end up getting some error like this
fatal unable to connect ... return code 22 bla bla
Follow are some pointers for help
  • Check your proxy setting (env|grep _proxy)
  • Check if you are behind the firewall. If so-
    • Either Disable firewall
    • or Tunnel through it if you know right port and host
      • Here is the script. Put this script in ~/.ssh/config
      • host proxy
        HostName <hostname>
        user <username>
        Compression no
        LocalForward 2224 gitorious.org:22

        host gitorious.org
        HostKeyAlias gitorious.org
        User git
        IdentityFile <~/.ssh/id_rsa (default, if yours is different put different file)>
        HostName 127.0.0.1
        Port 2224

      • Run ssh -N -f proxy
      • It would ask for few authentications etc. Do that. Now your git commands will run like a hot wire in butter
Trouble-Shoot 2:: When after making your changes you do git push. You are unable to push it. The trouble shoot is similar as above but one extra.
  • Check if you have push access right to that repository
How to clone a branch?
- You always clone the master. It will bring branch anyways.