How Tos, Tutorials, Tips and Tricks

Git

Almost 80-90 people visit How To: Install and Configure GitWeb everyday in search of setting up a web interface for their git repositories. Though gitweb is nice, it’s a bit painful to setup and the web interface is not that appealing. The other day I received this email from Klaus Silveira

Hello Kulbir,
I saw your article about installing Gitweb and i decided to send this shameless self-promotion. Maybe you could try my open-source project, GitList https://github.com/klaussilveira/gitlist

I’m looking for beta testers and supporters. FLOSS. 🙂

So, I thought I’ll just give it a try. Today, I got it working and was blown away by the amazing interface! It’s almost like a super simplified version of GitHub. I was so impressed that I immediately setup a demo website at git.gofedora.com for others to look at and fall in love :-)Another good thing about GitList is that it’s very simple to setup. Below is a step by step process to install and configure GitList to expose your public Git repositories to the internet.

What You Need?

Installing Required Packages

Most modern operating systems have the above mentioned packages installed by default. Even if you don’t have them already, you can use your OS package manager to install them quickly. To install on Fedora/RedHat/CentOS using yum, use the following command

[root@whitemagnet.com ~]$ yum install php git httpd

[root@whitemagnet.com ~]$ yum install php git httpd

For Ubuntu/Debian, use the following command

[root@whitemagnet.com ~]$ apt-get install php git apache2

[root@whitemagnet.com ~]$ apt-get install php git apache2

Assumptions

For setting up GitList, I am assuming the following directory paths and other variables.

GitList utilizes Apache’s mod_rewrite module to provide nice URLs. Make sure your Apache is configured to read .htaccess from the gitlist directory. Open your Apache config file (generally located at /etc/httpd/conf/httpd.conf or /etc/apache2/ports.conf) and look for the following

I have been using Git for years now and I am still a novice user. Actually, if you are an individual developer or work in a really small team, you don’t really need to go beyond using the basic stuff like cloning a repo, committing code, branching and pushing back to the origin repo. And that’s exactly what happened with me. Working alone most of the times and working in my own repos. I never felt the need to explore advanced usage.

Last week, we didn’t have internet at home for like four days. So, I thought I’ll read a book. I downloaded ProGit : The Free Git Book and started reading. It’s an awesomely written book. I learned a lot of new things about Git. A few more concept about using branches efficiently. If you are a Git beginner or looking forward to getting started with Git and you don’t like reading too much, I’ll suggest that you read at least first three chapters thoroughly. That along with a free GitHub account should be enough to get you going if you are not going to be a heavy Git user soon.

Summer has already started and we (a small group of current and ex-IIITians in Hyderabad) are planning to have some fun digging into Ruby on Rails and related technologies. If you are also interested in utilizing your summer in a productive and fun way, you can join us and share your knowledge while learning from the rest of the members at the same time.

Assuming that all of us know at least one programming language (C/C++/Python), below is the list of things we are planning to learn.

Ruby

If you already know a programming language, it’ll not be difficult for you to pick up Ruby.

RailsGuides is one of best and complete documentation for getting started with Ruby on Rails. It may look like a lot of content to beginners. If that’s the case with you, you can skip the guides in Digging Deeper section.

RailsCasts is like a sea of quality Ruby on Rails screencasts. Watch a few on topics where you may have doubts.

jQuery

We’ll be learning jQuery assuming that all of us are already familiar with JavaScript.

We’ll learn only basics initially and explore more as we start using it in a Rails project.

CoffeeScript

CoffeeScript is a language that compiles to JavaScript but it’s way more beautiful to look at and easier to read and understand.

We’ll learn about basic Git functions like cloning a repository, committing code, pushing code to a remote repository, working in different branches etc.

Go through Git Basics and we can learn more as we start using it full time.

We’ll be using GitHub to host all our code. If you don’t have an account already, get one.

We’ll learn these technologies while working regularly at our work places. Once in a while, we’ll meet and share our experiences and knowledge. The plan is to spend one or two weeks to go through basic stuff in all the topics. After that we can start a dummy rails project and learn more as we go.

If you are not in Hyderabad and still want to join, just start exploring and we can connect online! Happy Hacking!!!

As promised in my previous post, here is a brief howto on getting started with twython. The main advantage of Twython over several other python (or any other language) wrappers for Twitter API is that it works even when you are behind your organizations proxy.

Download Twython

You can download latest version of twython from twython page on github. You can either clone using git (if you have git installed) or can click the download button.

Install Twython

Once you are done with extracting the downloaded tar file. Change directory to twython and run these command as root.

Use Twython from Python Interpreter

[saini@bordeaux ~]$ python
Python 2.6(r26:66714, Mar 172009,11:44:21)[GCC 4.4.0 20090313(Red Hat 4.4.0-0.26)] on linux2
Type "help","copyright","credits"or"license"for more information.
>>># first of all, import twython module>>>import twython
>>># Authenticate your twitter account with your twitter username
... # and password with twitter.setup method.>>> client = twython.setup('Basic','myusername','mypassword')>>> client.authenticatedTrue>>>#Lets update our current status on twitter with some cool message.>>> client.updateStatus('Testing #twython. The coolest #TwitterAPI :)')>>># Now go and check your current status on twitter. Surprised!!!>>># Get your or anyone's followers>>> client.getFollowersIDs(screen_name='gofedora')>>># Output truncated.>>># Get help for any function.>>>print client.createFriendship.__doc__
createFriendship(id=None, user_id =None, screen_name =None, follow ="false")
Allows the authenticating users to follow the user specified in the ID parameter.
Returns the befriended userin the requested format when successful. Returns a
string describing the failure condition when unsuccessful. If you are already
friends with the user an HTTP 403 will be returned.
Parameters:
** Note: One of the following is required. (id, user_id, screen_name)id - Required. The ID or screen name of the user to befriend.
user_id - Required. Specfies the ID of the user to befriend. Helpfulfor disambiguating when a valid user ID is also a valid screen name.
screen_name - Required. Specfies the screen name of the user to befriend. Helpfulfor disambiguating when a valid screen name is also a user ID.
follow - Optional. Enable notifications for the target userin addition to becoming friends.
>>>

[saini@bordeaux ~]$ python
Python 2.6 (r26:66714, Mar 17 2009, 11:44:21)
[GCC 4.4.0 20090313 (Red Hat 4.4.0-0.26)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> # first of all, import twython module
>>> import twython
>>> # Authenticate your twitter account with your twitter username
... # and password with twitter.setup method.
>>> client = twython.setup('Basic','myusername','mypassword')
>>> client.authenticated
True
>>> #Lets update our current status on twitter with some cool message.
>>> client.updateStatus('Testing #twython. The coolest #TwitterAPI :)')
>>> # Now go and check your current status on twitter. Surprised!!!
>>> # Get your or anyone's followers
>>> client.getFollowersIDs(screen_name='gofedora')
>>> # Output truncated.
>>> # Get help for any function.
>>> print client.createFriendship.__doc__
createFriendship(id = None, user_id = None, screen_name = None, follow = "false")
Allows the authenticating users to follow the user specified in the ID parameter.
Returns the befriended user in the requested format when successful. Returns a
string describing the failure condition when unsuccessful. If you are already
friends with the user an HTTP 403 will be returned.
Parameters:
** Note: One of the following is required. (id, user_id, screen_name)
id - Required. The ID or screen name of the user to befriend.
user_id - Required. Specfies the ID of the user to befriend. Helpful for disambiguating when a valid user ID is also a valid screen name.
screen_name - Required. Specfies the screen name of the user to befriend. Helpful for disambiguating when a valid screen name is also a user ID.
follow - Optional. Enable notifications for the target user in addition to becoming friends.
>>>

So now you are ready to do wonders with twython. Write your own code and blog/brag about it 🙂

UPDATE : I recommend using GitList instead of GitWeb. GitList is much easier to setup and has a better web interface. Continue reading this post if you looking for GitWeb setup instructions specifically.

Well, if you consider just the web interface and committing part for your project, thats all. But things can be fine tuned further. Below are few hacks!

1. Enabling nice urls.

By default the urls for browsing repository via git web are pretty crappy and difficult to remember. The RewriteRule and RewriteEngine lines in your Apache configuration file (/etc/httpd/conf.d/git.conf) takes care of that and produce nice and clean urls.

Try the ls-remote command now and it should succeed by producing all the branches and tags in the remote repository.

But there is a problem, you have to run the above command after every commit to the remote repository. To solve this issue, you can enable post-update hook for the project’s repository in gitweb. Use the following command to enable it.

The above command will update the server info automatically every time you commit.

Thats all you need to do for setting up gitweb. I hope this will be helpful.

We are the world leaders in providing best MB5-858 and MB6-818 prep solutions. Our incredible offers for MB7-840 and 70-297 exams are accessible at reasonable prices; 70-236 is very rare in IT world sense.