git Cheatsheet

February 1, 2010 1 comment

When you’re new to git, it can get difficult to wrap your head around it at first. This is especially true if you’re migrating from subversion or when you’d rather spend more time writing your code than trying to learn git.

Git requires some learning, and you might as well spend the time doing it rather than wondering what just happened after running a command. Learn.github is a good place to start to learn the basics.

But even after spending some time learning git, there are going to be times that you’ve to painfully search the web/manual for basic stuff like working with remote branches or more complex stuff like handling a failed merge.

For the same reason, I’m creating this post as a reference point for myself to avoid repetitive searches. I’ll keep adding new commands here if and when I use them.

This is no way near to a complete reference for git and there might be better ways to do the things listed here. These are just the commands I use the most, in the manner I prefer to use them.

Basics

  • Commit and Stage all changes
    git commit -am "log message"
  • Push Changes to remote repo
    git push
  • Pull Changes to local repo
    git pull
  • Check current status of working tree
    git status
  • View diff
    git diff
  • Discard local uncommitted changes to a file (in this case, abc.txt)
    git checkout -- abc.txt

Branches ( Branch name is assumed to be ‘abc’ )

Working with local branches

  • Create a branch
    git branch abc
  • Switch to a branch
    git checkout abc
  • View all existing branches
    git branch
  • Remove a branch
    git branch -d abc
  • Merge a branch

    # In this case, merging abc into master
    git checkout master
    git merge abc
    

Working with remote branches

  • Push a local branch to remote repo
    git push origin abc
  • Delete a remote branch
    git push origin :abc
  • Setup a local branch to track a remote branch
    git branch --track abc origin/abc
  • Create a local branch, push it to remote repo. and then pull changes from it

    # Creating the new branch and switching to it
    git checkout -b abc;
    # Pushing the changes
    git push
    # Meanwhile someone else made changes to the remote version
    # Pulling those changes
    git pull origin abc
    # if you want to simply use 'git pull' to get the changes, do the following
    git config branch.abc.remote origin
    git config branch.abc.merge refs/heads/abc
    

    Alternative methods listed here.

Tags ( Tag name is assumed to be v1.0 here )

  • View all tags
    git tag
  • Create a tag referencing a particular commit using its checksum (annotated)

    # here commit checksum is assumed to be 98eda02.
    # to view the checksum of a commit, you can do
    git log --pretty=oneline
    git tag -am "v1.0" 98eda02
    
  • Push tags to remote repo
    git push --tags
  • Delete a local tag

    git tag -d v1.0
  • Rename a local tag

    	git tag NEW_TAG OLD_TAG
    	git tag -d OLD_TAG
  • Delete a remote tag

    git push origin :refs/tags/v1.0

Useful Git References

How gleeBox makes browsing the web faster and more fun

January 28, 2010 0 comments

gleeBox started out as a weekend hack project for me and Sameer. But, we ended up spending a lot more time working on it. Not that I’m complaining, I think we managed to build a tool that is really useful once you get used to it. We made our last major release (1.0) a couple of weeks back. From now on, gleeBox development will be carried out at ease (and not the 20 commits/day rate at which it was being carried out earlier ^^ )

If you’re not familiar with gleeBox, you should take a look at this screencast or read the user manual.

After continually using gleeBox for some time, I’ve discovered several ways in which it makes browsing and doing stuff on the web quicker and more fun. Here are some of them:

ESP Visions:

This is my favorite feature of gleeBox. What this means is, you can specify jQuery selectors for specific URLs and when you visit that particular page and open gleeBox, that selector will automatically be executed and all the matching elements will be highlighted on the page. You can TAB through them and press enter to execute a link.

This is especially useful on pages like the Google search results page, where all you would ever want to do is to go through the results. You don’t need to scroll using the mouse. This makes searching a lot more fun and less tiresome for the fingers.

This is also really useful for automating stuff, especially for pages where you have to click the same link everytime you visit them.

Several useful ESP Visions are listed on TipJar.

Default Link Search:

You start typing something and gleeBox highlights all the links on the page that match the text. This means you don’t need to take your hands off the keyboard to navigate the web.

Page commands and bookmarklet execution:

You can execute any bookmarklet by typing in

!bookmarklet-name

. There are also some inbuilt-commands. A couple of examples are:

Open the RSS feed of the current page in Google Reader so that you can easily subscribe to it

!rss

Share current page through mail, gmail, facebook, twitter, etc.

!share m / g / fb / t / ...

All of them are listed in the user manual.

Bookmark Search:

If turned on, gleeBox searches browser bookmarks if no links are found matching the entered text. This is useful, instead of manually going through a long list of sites in the bookmarks menu.

Yubnub commands:

You can execute yubnub or quix commands preceded by

:

A couple of examples are:

Search twitter for gleeBox

:tw gleebox

Search IMDb for avatar

:imdb avatar

Scraper commands:

Select Linked Images

?img

You can also define custom scrapers. Example: This will select all shared links on twitter.com

?t - a.web 

If you’re an advanced gleeBox user, you should go ahead and share tips on Tipjar. You can login using your Twitter / Facebook / other accounts and start posting right away from the main page.

Twitkut v2.0 to be an OAuth Gadget

September 28, 2009 0 comments

I’ve been working on the next version of Twitkut in whatever little free time I’ve had in the past couple weeks ( mostly weekends ). The next version of Twitkut will feature a number of new and exciting features, the most major one being support for OAuth. Some of the features have already been deployed on Orkut:

1. Displaying user tweets in the Orkut profile page (deployed): I had to rewrite the whole code for this due the new server-side templates and data-pipelining standards enforced by Orkut. It has certain limitations in that you cannot click on any link that links to any external source. Clicking on the user’s pic or username leads you to the application page.

2. OAuth Support: Twitkut will now enable you to authorize it with your Twitter account via OAuth. Doing this will enable you to post updates from Twitkut, add your Orkut friends as your Twitter friends and many more things (listed as separate features). I chose OAuth since then you won’t have to worry about me storing your Twitter passwords.

3. Post updates from Twitkut: If you enable OAuth, you’ll be able to post updates to your Twitter account from within Twitkut.

4. Follow your Orkut friends on Twitter: Enabling OAuth will enable you to follow your Orkut friends on Twitter from within Twitkut.

5. Selective Updates: This will be similar to the “Selective Twitter Updater” Facebook app. You will able to selectively display updates on Twitkut by adding a hashtag to the end of updates similar to “#orktw” or “#orkut”. I’ve still to decide upon the hashtag. Only the updates containing the hashtag will be displayed on Twitkut.

Unfortunately, the popular demand for automatic updates to the user’s activity stream ( without the user having to visit the application page ) won’t be possible due to the limitations enforced by Orkut. If Orkut ever allows it, it’ll be the first feature I’ll add.

I cannot promise if and when I’ll add all these features. There are too many variables, time being the biggest one. You can keep abreast with the latest updates to Twitkut by following @twitkut.

You can also suggest features that you’ll like to be added to Twitkut as comments to this blogpost or as @replies to @twitkut.

Enabling Twitkut with OAuth has been/will be a complicated task. I’ll probably write a separate blog on writing an Opensocial OAuth Gadget.


PollBol, a Polling Web App

October 22, 2008 2 comments

PollBol

Update: PollBol is currently down due to server deployment issues. Take a look at the screenshots instead.

PollBol is an exciting web app that adds a twist to conventional polling by adding an additional social aspect to it. After making FriendComparé, which was a mashup making use of the Last.fm API, I wanted to make a more independent app that maintained its own data.

Even so, I fully support the idea of making use other apps’ APIs. It makes it easier for the users to adopt since it builds on the functionality of the more popular app. And so, FriendComparé has had comparatively far more visitors as compared to PollBol due to the popularity of Last.fm.

With PollBol, I had to think of a development platform that would allow me to complete the project within my summer vacations. And what better for agile development than Ruby On Rails. It was exciting to use Rails as it divides the entire project into three parts: Models, Views and Controllers. And this makes it easier to plan on the various modules of the project.

read more…