For all the content which do not have a category

5 least used Git hacks

Git is undoubtedly the best thing happened to the programming lifecycle. To the people who don’t know git, it is a widely used version control system for software development. While git being git , saves most of the troubles software engineers having related to versions, collaborating, going back and forth in developing features and adding them to the software, there are lot of commands in git which are not very commonly used but saves your time in a great deal.

(This article assumes that you have a basic understanding of git workflow)

Git stashing

Whenever you have any uncommitted changes in your git repository and you want to change the branch, you may have come across the following error.


When you have uncommitted changes which you still want to keep, then you just have to type “git stash”. It will record both your staged and unstaged changes internally. When you are ready to comeback to your incomplete work you just have to type the command “git stash apply”. This command will only apply your most recent stashed changes.

You can see your stash history by “git stash list”, It will give you the list of stashes which are stored. If you want to apply an older stash, you have to specify the name with the command like “git stash apply stash@{1}”.

Capture stash list

Git doesn’t provide a command like “git stash unapply” to unapply a stash. If you want to unapply the changes that came from the stash , you have to do it by simply retrieving the patch associated with a stash and apply it in reverse using “git stash show –p | git apply -R”. This will revert the changes in the most recently applied stash. If you want to specify a stash to unapply you can use the above command as this “git stash show –p stash@{1} | git apply -R”.

If you are more into it , you can also create a git unapply command yourself so that you don’t have to remember the whole thing or google it everytime you need it by using aliases which is discussed in the last section in this blogpost.

Following are few more commands associated with stash

git stash apply –index” – When the stash is applied using the normal “git stash apply” command then your previous staged changes will be unstaged. If you want your previous position with all your staged changes staged, then you have to use the apply command with “–index”. This will give you the original position you were in before stashing.

git stash drop stash@{0}” – When you apply a stash using “git stash apply” command it will continue to stay on your stash list. To remove your stash from the list you can use the above command.

git stash pop” – If you want to apply the stash and immediately remove from the list, then you can use the above command.

One of the other use cases of using stash can be like this. You have two feature branches in your git repository named feature1, feature2. You start developing something in feature1 branch and suddenly you figure out this is not something you need in feature1 branch, but needed in feature2 branch. All you have to do is stash the changes, switch the branch to feature2 from feature1 and apply the stash. Applying the stash might cause you merge conflicts. But if you are using git you should have lot of experience in resolving merge conflicts. So I am not going to focus on them here.

Git reset

This is not very uncommon command as you may have expected. But I am sure the only command you use all of the time is “git reset –hard”. But there is more to the reset command.

If you want to unstage a file or set of files from the staging index, you can use the “git reset” or “git reset <file_name>

If you have a commit to undo you can use “git reset –hard HEAD~1” or “git reset –hard“. 1 can be replaced by number of commits you want to undo. If you want to move some commits to a separate branch, all you have to do is make a branch from the branch currently you are in and then undo the commits. In this scenario you will have the commits safely on the branch you created new.

Suppose while you are working on a certain branch and suddenly you got to fix a bug in another branch. But your current work is not completed. So instead of stashing them you just commit the changes of the working directory and checkout the other branch and fix the bug. But when you return to your previous branch, the last commit of it would contain incomplete work. So you can use “git reset –soft” to revert the commit and keep the changes in the index. So you can start completing work from there.

If you want to remove a file from the index before a commit you can use “git reset <filename>”.

Git ignore

There are standards defining what types of files you should commit and not. If you are a collaborator of a large project, you may have come across what kind of files to commit and not. Most probably these are the files related to your IDE. You can use a .gitignore file in your repository to mention all the files which should not be tracked intentionally. A .gitignore file should be committed in your repository in order to share your ignore rules with other collaborators. Github provides a list of recommended .gitignore files for popular operating systems, environments and languages. (https://github.com/github/gitignore)

But if you have a file which is already tracked by your repository adding that to the .gitignore file will not stop git from tracking it. So you have to manually remove it.

Each line in .gitignore file specifies a pattern . # denotes a comment. ‘!’ can be used to negate patterns. Sample .gitignore file would look like this

#Complied Object Files





# Precompiled Headers



Git cherrypick

This is the most useful command which will get out of you from most of the problems. Git cherrypick allows you to merge a single commit from one branch to another. This is very useful in situations which you do not merge the whole branch because of inconsistencies in versions and etc. cherrypicking is very simple. You have to first get your hash of the commit. You can use git log or any other preferred method. If you are using github the yellow highlightes numbers represent the hash associated with each commit in the following picture.


Then all you have to do is use the command “git cherry-pick <hash>” in the branch you want to apply the commit.

Git aliases

Aliases is the most amazing concept of git which will let you own it. Here is how it happens. If you are too lazy to type the git commands you can add short aliases for them. For example let’s take the command “git checkout” . You can create an aliase “c” for it by using the following command “git config –global alias.co checkout”. Then next time when you need checkout you just have to say “git c” instead of “git checkout”. As we discussed earlier in the stashing section you can create your own “git stash unapply” command using “git config –global alias.stash-unapply ‘!git stash show -p | git apply –R


Resources: https://git-scm.com/docs

GHCI Preconference Tips

Since GHCI (Grace Hopper Celebration of Women in Computing India) is getting near , here are some tips for the first time attendees to make your experience a comfortable one.

Plan your travel itinerary.

If you are an outstation attendee and haven’t been to Bangalore before, it’s better to plan your travel itinerary before arriving at Bangalore. Plan the travel details from the airport to your accommodation and, from your accommodation to the conference. If you are unfamiliar with the local language and area, you can always use the Google map offline feature and save the route beforehand so that you can even use the Google map with the gps to identify your location and route without an internet connection.

Plan the sessions you want to attend beforehand.

In GHCI there are several sessions going parallel. So deciding the sessions which you want to attend can be a little bit tricky, since all the sessions looks promising. So before coming to the conference take some time and read the detailed version of agenda and description of sessions. Never judge the session from its name. Go through the detailed description of each sessions and figure out the sessions you need to attend.It’s better to be prepared early to avoid last minute mistakes of missing your favorite sessions. Remember that during the conference sometimes the sessions can change and the changes will be notified. You can also use the Convene app for the conference. Believe me, it will make your life easy.

Go to the conference venue early (first day).

In  the first day, registration ques tend to be long. To avoid the long ques get there early and then you have the time to get familiar with the conference venue before the conference starts.

Vi To the rescue!!


(You can skip this part and start straight from the introduction.)

Two months ago I would never have thought that I will end up writing a blog post about vi or even use vi as my primary code editor. I was more of a IDE type of person. I have experience is using CodeBlocks, Netbeans, Eclipse, IntelliJ IDEA and Visual Studio.

My first IDE was CodeBlocks which I used to write small programs in C, when I was learning to program. Then When I started development in Java I moved in to Netbeans. The transition was a swift one at that time, because I was only using CodeBlocks for few weeks. Since then Netbeans was my favourite IDE until I started using Eclipse. I had to move to Eclipse because I started Android develeopment and it was bit hard to adapt to Eclipse from Netbeans. But when the time passes and when I get familiar with Eclipse, I started loving Eclipse in the same way I loved Netbeans. Then again due to a certain project requirement I had to code in IntelliJ IDEA. At first it was really an eyesore for me. I didn’t even like the look and feel of IDEA. But as soon as I continue to work in IDEA, I figured that it is far more easy and efficient than eclipse.

Given that background of IDEs, I was never a fan of using text editors as code editors. But due to  a certain work requirement, I was asked to use vi as my primary code editor and that is for a language that I am not even familiar with. Needless to say the the learning curve became very high. I had to learn a new language and on top of that do it on a text editor without entering the comfort zone of IDE.

Reluctant to use Vi as much as I do, my first approach was coding in visual studio and copy and paste it in the Vi. But I was not very pleased with the user experience of Visual Studio. In a very short time I’ve had enough of Visual Studio and thought what the heck, I don’t need auto completion. Determined to adapt to vi I started using it a few days back. And now I am completely loving it.


Vi is a text editor which is designed for Unix systems. Vi’s origin goes a long way back to ‘ed’, In between Vi and ‘ed’, there are several text editors such as ’em’, ‘en’ and ‘ex’, which helped ‘ed’ to evolve in to Vi. Vi is actually the visual mode of ‘ex’ which is written by Bill Joy. But later Bill found out that people actually spend most of the time in the visual mode. Then he separated and make Vi directly accessible to the users. If you are more interested in Vi’s origin and history, you can go through the Wikipedia article of  Vi.

Vi has two modes; normal mode and insert mode. In normal mode, the keystrokes become commands where as in the insert mode they become the text inserted in the document. You can switch between modes by using ‘Esc’ (for normal mode) and ‘I’ (for inserts mode) keys.

One of the most impressive traits of Vi is you never had to take your hand away from the keyboard (to the mouse) when you are using Vi. It’s beauty lies in its configurability which provides a customized experience. On top of that you would never want to wait forever until your IDE starts. Vi loads instantaneously and allow you to do your work in the way you want to do it. If you want more testimonials on Vi users, read answers to the following Quora question.

Although at first it seems hard to adapt, at the end of the day you will be happy that you started. Below are some resources for Vi beginners , which helped me to get a hold on Vi.


What if I told you that you can have the auto completion and file explorer in the Vi too? Yes. It’s possible. Vi comes with a vast amount of useful plugins. Among which Following two are my favorites.

  • Nerd Tree : Allows you to perform simple file system operations and display the hierarchical tree structure.
  • You Complete Me : Fast code completion

If you have any better resources for learning or using Vi/Vim feel free to comment. 🙂

I am a feminist, and I do not hate men

Lots of men think that being a feminist is just taking charge against the entire male population. Surprisingly, there are some women who thinks the same. But I suggest before you come and criticize feminists, just do some research first.

So what exactly is the meaning of “Feminism”? As per oxford dictionary, “Feminism is the advocacy of women’s rights on the ground of the equality of the sexes”. As per Wikipedia, “Feminism is a collection of moments and ideologies that share a common goal; to define, establish, and achieve equal political, economic, cultural, personal and social rights for women”.

So where has the “hating men” part has come from? How did that notion emerged out of nowhere and established grounds on “feminism”?

I believe that this was because that when women try to achieve their equal rights (positions), men fear that women are challenging to their stability on these positions and eventually end up stealing them. I have only a very short experience in the software industry. As per what I have experienced, men do not hate entering women in tech. In fact they love it. But the problem arises when women try to climb the ladder, Men care and nurture women when they are subordinates, but when the women try to climb up the career ladder, men tend to block it.

More over, men take the message of feminism in the wrong way. A very good example would be the women empowerment video of Deepika Padukone and how the society responds it. I believe it is the time to understand that feminism is not hating the entire male population, but empowering females to do what they like, what they want and what they are capable of.

In concluding note, I couldn’t resist sharing this video, for the sake of females who proudly say that they are not feminists.

How to extract the images in a Google Doc

Have you ever face a situation where you have access to a certain document with some images and you want to use the images it has for some other purpose. If you want to get these pictures in a word document what you have to do is just copy the image and paste it in the word document. But what happens of you want these images and images only to upload in some wort of web page??
Recently I faced such scenario. When I am writing a research paper using WriteLatex online Latex editor I wanted to include some figures. My friend has shared those figures in a Google Doc and has sent a link to me. Since I wanted the images to upload to the Latex site, downloading it as a word document or pdf did no help. But then I found the solution.
In Google Doc you have 6 download options. If you want to download you have to click “File” menu , go to “Download as”. In the 6 options the last option is download as a web page. If you click that the document will be downloaded as a .zip file. It will contain .html file of your document and a separate folder for images. You can get the images separately if you go to that folder.

Ada Camp, Banglore – Two Awesome Days

Ada Initiative is a nonprofit organization which supports women in open technology and culture.  Ada Camp is a major event organized by Ada Initiative.  It is a series of conferences (Actually in unconference format, more on that later) aiming to increase the women participation in open technology and culture. In 2014 there were 3 Ada Camps in 3 continents.  The participation to Ada Camp is by invitation only. You can apply through the Ada Camp web site if you are interested and they will let you know if you are selected to attend. I was very lucky I got the chance to participate as an attendee in the Ada Camp, Banglore which was held in 22nd and 23rd of November, 2014. I also got a travel scholarship from Ada Initiative which made me possible to come to India and participate Ada Camp.

Rather than going in detail about the conference I will first introduce my self and what are my contributions in open technology and culture. Since being a final year undergraduate studying in Computer Science and Engineering in Sri Lanka, I am very much familiar with open source software. But my expertise does not end there. I am a Wikimedian and Wikipedia article writer in Sinhala. I translate Wikimedia contents and Wikipedia articles. I also contribute to the new Wikimedia project Wikidata which is aiming at structuring Wikipedia.

Ada Camp was held at Red hat office which is located in 11th floor in IBC Knowledge Park. The place was very nice and have a really nice view of Banglore.


The considerations taken by the organizers to make the ada camp experience a comfortable and a pleasant one to all the attendees should be highly appreciated. From the registration table we get a tag with a coloured lanyard to write our names and have it with us, so we all can communicate with each other easily. The lanyard logic made every one’s life easier representing the preference to be photographed. It goes as follows:

Red : Do not take photograpghs, do not even ask.

Yellow: Should ask and get the consent before photographing

Green : no restrictions in photograpghing

They have even given consideration in to small things such as reminding to bring a sweater if the AC is too cool. Alex and Suki did a great job in hosting the event.

Ada camp actually started with the Friday night reception which was held on 21st November. It was a networking event where the attendees get the chance to get to know each other over the dinner and snacks.

Ada Camp started off with an impostor syndrome workshop. Impostor syndrome is the feeling that you aren’t actually qualified for the work you are doing. It is a very common feeling among women in tech. Even I have that feeling to a certain extent. The most interesting thing happened during the workshop was giving and receiving compliments.  It was actually a surprise to figure out that we can compliment others very easily, but are uncomfortable in receiving compliments.

Ada camp is an unconference. An unconference is a participant driven meeting.  After the impostor syndrome workshop the unconference procedure started. The first day was dedicated to discussion sessions as the second day was more focused on workshops and hands on lessons. These sessions and workshops covered a wide area. These are not pre-scheduled. In the morning anyone can propose and pitch the sessions and others can vote. So according to the votes the agenda is created. There are parallel sessions which are run across a couple of rooms and attendees can choose what they want and attend to that. If you feel like you want to go to another session while you are in a different one, you can stand up and leave the session without any hard feelings.

IMAG0599 IMAG0601 IMAG0604Two of the most interesting workshop sessions I attended was the Mozilla crafting community and Arduino and Raspberry Pi workshop. In the crafting community workshop we made thank you cards for our hosts.

IMAG0609One more thing which was new to me was lightning talks. They were 90 seconds talks that you can talk about anything. You can submit your talk proposal before for the ease of organizing. The lightning talk session was after lunch each day.

Ada camp was the best experience in my life where I was able to share my knowledge and learn from others. Everybody participated was willing to learn and willing to share. I was highly motivated to do my best to increase the number of women and their participation in technology. I was amazed how people have initiated things to achieve this aim and successfully expanding their projects.

I can conclude that Ada Camp, Banglore was a big success and I wish Ada Initiative all the best to keep up the good work. If you want to support Ada Initiative and their future work you can support it by donating.

Donate now


GHCI – 2014 An Experience of a Lifetime

Ever since I returned home from Grace Hopper Celebration, India I was hoping to write this blog post. But due to my extremely busy schedule I couldn’t find time. Although it has been almost a month, GHCI excitement is still not out of my system. It was one of the most awesome periods in my life.

Since I am from Sri Lanka, going to Banglore is another type of an adventure which I am not going to focus on here. (May be in another blog post) The Grace Hopper Celebration was held at The Lalit Ashok, Banglore. Scholars were given accommodation in nearby hotels. Since I arrived on 19th my hotel was 37th Crescent Hotel. It was really nice and the staff was very much helpful and the food was great!

After an adventurous day and a good night sleep, on 20th morning we were so excited about what will happen in the conference. We knew it would be a whole different kind of experience. But never hoped that it will have this much of impact on our lives. When we enter Lalit Ashok Hotel on 20th morning, we already saw the difference. The vibrant colours made the atmosphere energetic.

After registering and collecting the souvenir gift pack (two bags full of goodies :D) we went to Kalinga Hall where the welcome presentation and keynote speech to be held.  The conference started off with a grand way with a very inspirational and motivational keynote speech by Jayshree Ullal, the president and CEO of Arista Networks.

Next was the panel discussions. They were categorized in to different themes and we only were able to attend one at a time because the sessions were parallel. My first choice among the first set of sessions was “Tapping in to my inner Prada”. I was interested in this session as soon as I saw the name for the first time. It was the most interesting and awesome session I attended throughout the conference.

The aim of the panel discussion “Tapping in to my inner Prada” is to discuss how our appearance impact on our career growth. I have to say that the panelists were amazing. They covered the every aspect of the problem themselves. As a women we all have the problem that our working environments are so casual such that if we stepped out of the denim and t shirt dress code and wear something different and elegant, we are bound to look odd.  In the session they talked about how we want us to be seen and how to achieve that. The panel discussed about how the way we dress and our clothing affects and how we can choose the way we dress to display authority. It also focused on grooming, communication and body language.

Another important session in the first day was the keynote speech by Jane Moran, CIO of Unilever. One important thing I learned from her speech was that if we want something in our career we’ve got to ask it. We have to speak for ourselves and if we think we are qualified, we should go and ask for it. With the Asian culture women are little bit of reluctant to this kind of behavior.

The evening followed with a career fair with all the important companies like Google, Facebook, etc. The networking and entertainment dinner at the poolside was also awesome.

The most interesting session in the second day was the keynote by Laxmi Partury. She talked about how she solved the problems she faced. Specially as Asian women we have to face lot of problems regarding our careers and relationships. By our culture we are bound to our families and tend to give priority to family rather than the career.

Two other sessions that I loved were “Discover and build your strength” and “The career guidance never given”. They talked about how we choose the career according to our strengths and how to progress in it.

The most important thing happened in the conference is it changed my mind about career women. During the two days I got the chance to speak and see a lot of women who has gone up to the top of their career ladders while balancing and caring for their families as well. I always thought that balancing family and career has a limit. At a certain point as a mother, as a wife and as a daughter you will have to give priority to your family and you will eventually be stuck at some point in your career. But GHC taught me it is still possible to balance the career with family life and that is entirely up to the individual. “If there is a will, there is a way :D”.


Thank you Anita Borg India for the wonderful opportunity to attend GHC India. It was a well organized great event. I think every girl in computer science should attend GHC even for a once in their lifetime.