GIT: Squash (Comitting multiple files to gerrit under one review)

I am showing here how to push multiple files under one gerrit review.

Pre-requisites: You need commit-msg hook configured in your local repository.
1- scp -p -P :hooks/commit-msg .git/hooks/
2- curl http:/:port/tools/hooks/commit-msg

Steps:
1- Work and commit usually in your local copy
2- git rebase -i HEAD~6 (6 is the numbers of version you want to squash together)
3- pick base version and replace "squash" for "pick" for the commits you want to squash together. All squashed commits will go together with the "pick" one into gerrit review.
3- Modify changeId in rebase process when asked (make sure changeId should be same as that of already created review process)
4- push to gerrit

Git Stash

Stashing your changes: It saves your local changes on stash stack and revert your working copy to HEAD
git stash save
bash-3.2$ git stash save
Saved working directory and index state WIP on testing: fb1f22c This is test commit commit-amended
HEAD is now at fb1f22c This is test commit



Viewing your stashed changes:

git stash list
bash-3.2$ git stash list
stash@{0}: WIP on testing: fb1f22c This is test commit commit-amended
stash@{1}: WIP on testing: fb1f22c This is test commit commit-amended


Applying your stash :
git stash apply stash@{0}

OR
This applies latest stashed copy of your changes
git stash pop


Deleting Stash
  • Delete Particular Stash:
    git stash drop stashId
    bash-3.2$ git stash drop stash@{0}
    Dropped stash@{0} (3b88e6278d1bb2bcf600ff9a5dde50116361a200)
  • Delete All Stashes:
    git stash clear

Installing Hudson on Mac OS X (Snow Leopard)

This is a 5 step process:
  1. Install hudson.war in your download directory : ~/Downloads
  2. Create a hudson directory in your home folder : mkdir -p ~/hudson
  3. Copy hudson.war from ~/Downloads/ to ~/hudson directory: cp ~/Downloads/hudson.war ~/hudson/hudson.war
  4. Run hudson at port of your choice: java -jar ~/.hudson/hudson.war --httpPort=8082
  5. Configure Hudson Jobs !

Creating Multi level directory in Linux

Linux doesn't create a directory at an unknown path. For example- If I want to create a directory firstLevel/secondLevel, firstLevel should already exists. Otherwise, give -p option with mkdir like this:

mkdir -p firstLevel/secondLevel

This will create firstLevel first, and then secondLevel under it.

Steps to create a Gerrit review

Git and Gerrit have been quite confusing together sometimes. Specially, in lack of good documentation. Doesn't seem like lot of people are using them efficiently.   
In this post, I am trying to explain that how to create a review in gerrit and modifying a file under one review multiple times.

Pre-requisites: You need commit-msg hook configured in your local repository.
1- scp -p -P <gerritserver>:hooks/commit-msg .git/hooks/
2- curl http:/<gerritserver>:port/tools/hooks/commit-msg

Step-1. Change a file
Step-2. Commit this file using: git commit -a -m "commit message"
Step-3. Push change to gerrit to create a new review. git push gerrit HEAD:refs/for/branchname
Step-4. Amend a file for the next change: git commit --amend <filename>
Step-5. Iterate Step-3,5

Scheduling Repeating Local Notifications using Alarm Manager

Learn about Scheduling Repeating Local Notifications using Alarm Manager in this post .