Lets say that Deep is working on the next generation

*Math package*. He aims to write the next generation Factorial program (yea yea! I know, how hard could that be). This program would be the highly optimized and best performing Factorial program ever!

He is currently on the master branch i.e. the default branch.

**Lets start:**

Deep starts of with the simplest solution first. He writes the code to find the factorial of zero. Here is what it looks like.

Deep decides that, he is at a logical point (the point at which all his tests are passing and code is in a good shape)

He has achieved the unthinkable, the factorial of Zero is found! Wow! what a discovery! Lets commit this change to GIT.

He moves on, adds more code to find the factorial value of 1.

Again, a logical point. Time to commit.

Next, he adds code to find the factorial of any given number

Thats quite some progress. Lets commit again.

At this point, Deep thinks, he has developed the ultimate algorithm to find factorial of any number! He decides to push his changes to SVN and make them public (so that other people can appreciate the awesome code!)

Pushing changes to SVN

World has one less problem to solve! Deep decides to take up another challenge, he decides to write the code for Fibonacci series!

He starts off in the simplest possible way. Fibonacci value of numbers less than 2 is 1.

Logical point, need to commit to GIT.

**Turning point:**

At this point, Deep's boss, comes over and tells Deep, you moron, dumb a**, @#$#, you don't know that, the Factorial of zero is not zero its 1! Fix it! And fix it now! Deep is all terrified! He has to fix this goof up as soon as possible! After the initial hysteria! He says to him self Aal izz well!

Current

*git log*looks like this:

As you can see there is one commit on the top, which is not yet pushed to SVN. He does not want to push the Fibonacci commit to SVN but still wants to fix the issue. He does not want to lose the Fibonacci change either!

Basically he wants to work on two things, Factorial bug fix and Fibonacci series!

GIT has awesome support for working on multiple streams of work! Let see how GIT enables Deep to deal with this situation.

**How do they do it?**

He decides to create a

*bug_fix local branch*. This

*branch*will have the code that points to the current code in the SVN repository. This

*branch*will not have the Fibonacci commit. This is how its done

GIT log will show that this branch does not have the Fibonacci commit

This is because we have created the

*bug_fix branch*to point to the current code in SVN.

Next, Deep fixes his goof-up like this

Committing,

Since boss wanted this fix checked-in asap, pushing to SVN

The GIT log will show that we have pushed only the bug fix to SVN

Boss is happy! The goof-up is fixed!

Back to work! Lets continue coding on the Fibonacci series. Remember? That code is still in the master local branch. Hence, to continue working on the Fibonacci series we need to

*switch to the master branch*.

Before moving any further, lets get the latest from SVN

GIT log will show that, we have received the commit that fixed the goof-up, and the Fibonacci commit is placed right on top of it!

**End result:**

- Boss is happy because Deep fixed the goof-up pretty fast
- Deep is happy because he did not have to revert, patch or do any kind of circus to work on multiple streams of work!
- World is happy because, optimized Factorial program is available :)

Thats all folks! Is this example enough? Do not waste any more time Go GIT it!

## No comments:

## Post a Comment