Vikas Gupta: Software architect

Archive for the ‘Uncategorized’ Category

Git Rebase Explained

Posted by Vikas Gupta on November 19, 2012

Using git rebase, you can rewrite the history of a repository in a variety of ways.

rebase takes a series of commits (normally a branch) and replays them on top of another commit (normally the last commit in another branch). The parent commit changes so all the commit IDs are recalculated. This can cause problems for other developers who have your code because the IDs don’t match up.

There’s a simple rule of thumb with git rebase: use it as much as you want on local commits. Once you’ve shared changes with another developer, the headache is generally not worth the trouble.

git rebase takes a branch (the most common use), a tag, or a commit ID to rebase on top of.You can also pass the –rebase option to git pull, causing it to perform a rebase instead of merging the upstream changes into your local branch.

git rebase requires a clean working tree—that is, a working tree with no modified files. If you have changes that you’re not ready to commit, you can stash them until you’re done.

A conflict might arise during the replaying of commits. Like a conflict during a regular merge, a conflict happens when two commits modify the same line of code. git rebase stops when this happens and asks you to fix the conflict and then continue.

You tell Git you’re ready with git rebase –continue.

You can also skip a commit that’s causing a conflict by calling git rebase –skip. That could lead to further conflicts, however.You can abort the rebase too with git rebase –abort.

There’s always a safety net if you need to undo a rebase after it’s completed. Git points ORIG_HEAD at the commit before major changes like git rebase are run.You can use git reset to reset your repository back to that original.

To rebase your current branch against master, use

git rebase master

The following image shows the organization of commits before and after a rebase.

 

Advertisements

Posted in Uncategorized | Leave a Comment »

Git: How to create a new Repository

Posted by Vikas Gupta on October 16, 2012

Repositories in Git are stored on your local file system right alongside the code they track.You create a repository by typing git init in the directory that you want to start tracking files in.

There are two repositories in Git to collaborate with others: a private one and a public one. Private repository, is where you do all your work. It’s the repository with the working tree.

This two-tier system gives the ability to track local experimental changes while only sharing changes via your public repository that are ready for others to work with.

git init creates a .git directory in your current directory and initializes the Git repository inside that. Once the repository is initialized, we need to add (using git add) and commit (using git commit) the files in the repository.

With an initialized repository, you have a working tree that you can interact with. Working tree is the latest copy of the repository.

Create a repository.
prompt> mkdir test-repository
prompt> cd test-repository
prompt> git init

Add some files in the test-repository folder. To add and commit the files in the repository, use the following commands.

prompt> git add .
prompt> git commit -m “some commit message”

That’s it, with this commands, you have created a new repository and added few files in it.

In the next post on Git, I will discuss about cloning an existing repository into local machine.

Posted in Uncategorized | Leave a Comment »

Intalling VMware Player on Ubuntu 12.04

Posted by Vikas Gupta on August 18, 2012

In my pursuit to learn Hadoop, I decided to use one of the Hadoop virtual machine images provided by Cloudera before actually installing Hadoop on my Ubuntu 12.04. Cloudera provides virtual machines for VMWare, KVM and VirtualBox. For more information about Cloudera Hadoop virtual  machines, please visit Cloudera Demo VM . I decided to go with VMWare image. This required me to install VMWare player. In this blog, you will find step by step instructions to install VMWare player and solution to the problems faced during this process.

1. While looking for VMWare Player(vmplayer) installer, i found that vmplayer installer is not provided by the repositories, you have to instead download it from VMware website. While downloading please make sure that you download the latest and correct version for your architecture. That is, if you’re running the 32-bit version of Ubuntu, get the 32-bit version, and if you’re running the 64-bit version of Ubuntu, get the 64-bit version. To find out the version of Ubuntu running on your computer, type in uname -m  from the terminal and press enter. If the result is x86_64, you’re running the 64-bit version of Ubuntu. If it says i686, you’re running the 32-bit version of Ubuntu.

2. The downloaded file is VMware-Player-4.0.3-703057.x86_64.txt for the 64-bit version. The download will vary depending upon Ubuntu version(32-bit vs 64-bit) and version of the vmplayer. Before installing vmplayer, check the file permissions of the downloaded file. You need to have execute permissions on the file. If you do not have execute permissions on the file, please execute the following command to change the mode of the file to have execute permissions.

chmod +x VMware-Player-4.0.3-703057.x86_64.txt

3. The installer may need to build and install kernel modules, so it’s advisable to make sure you have the necessary packages to facilitate this. Run uname -r. The output should end in genericgeneric-pae,server, or virtual. If it doesn’t end in generic, replace generic below with whatever it does end in.

sudo apt-get update
sudo apt-get install build-essential linux-headers-generic

4. Now run the installer. You have to run it as root, so use sudo:

sudo ./VMware-Player-4.0.3-703057.x86_64.txt

The rest of the installation process is guided and graphical. While you had to run the installer as root, you do not generally need to (and should not generally) run vmplayer as root after you’ve installed it. Occasionally, after an update to your kernel or vmplayer, vmplayer may ask you to allow it to build and install new kernel modules as root.

5. While trying the run the vmplayer, i got an error that vmplayer is not able to start the network services. After googling on the net, I found that there is a patch for that. To install that patch, please execute the following commands

wget http://webupd8.googlecode.com/files/vmware802fixlinux320.tar.gz
tar -xvf vmware802fixlinux320.tar.gz
sudo ~/vmware802fixlinux320/patch-modules_3.2.0.sh

My vmplayer ran fine after the following steps, I hope after following the above steps, you also have a problem free installing of the vmplayer.

Posted in Uncategorized | Tagged: , , | Leave a Comment »