Vikas Gupta: Software architect

Archive for November, 2012

Why MongoDB?

Posted by Vikas Gupta on November 21, 2012

A database is needed to persist the data of an application. We have been successfully using relational databases to do so. They are mature and well known. So, why use a new technology like document based database to store the web application data. Let’s explore the reasons by looking at the features of a commonly used document based databases, Mongodb.  Read the rest of this entry »

Posted in MongoDB, NoSql | Tagged: | 1 Comment »

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.

 

Posted in Uncategorized | Leave a Comment »